diff options
author | Gaming4JC <g4jc@hyperbola.info> | 2020-01-19 09:57:36 -0500 |
---|---|---|
committer | Gaming4JC <g4jc@hyperbola.info> | 2020-01-26 15:50:42 -0500 |
commit | d163c367d9ee5f13769b8580b97bcc511fdd13cd (patch) | |
tree | d8fba280f76b3ff92d5bf1c4d574731ab956f662 /parser/html/nsHtml5TreeBuilderCppSupplement.h | |
parent | 9bf83c6a785ba7463822a159cdaf9eb06ece3690 (diff) | |
download | UXP-d163c367d9ee5f13769b8580b97bcc511fdd13cd.tar UXP-d163c367d9ee5f13769b8580b97bcc511fdd13cd.tar.gz UXP-d163c367d9ee5f13769b8580b97bcc511fdd13cd.tar.lz UXP-d163c367d9ee5f13769b8580b97bcc511fdd13cd.tar.xz UXP-d163c367d9ee5f13769b8580b97bcc511fdd13cd.zip |
Bug 483155 - Put content creator function pointers onto nsHtml5ElementName.
This is all the manual work for Bug 483155, minus the added functionality to disable SVG and MathML which can be done at any time and are out of scope.
Tag UXP Issue #1344
Diffstat (limited to 'parser/html/nsHtml5TreeBuilderCppSupplement.h')
-rw-r--r-- | parser/html/nsHtml5TreeBuilderCppSupplement.h | 72 |
1 files changed, 47 insertions, 25 deletions
diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index 6121c6186..61906d53c 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -68,9 +68,10 @@ nsHtml5TreeBuilder::~nsHtml5TreeBuilder() } nsIContentHandle* -nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, - nsHtml5HtmlAttributes* aAttributes, - nsIContentHandle* aIntendedParent) +nsHtml5TreeBuilder::createElement(int32_t aNamespace, + nsIAtom* aName, + nsIContentHandle* aIntendedParent, + nsHtml5ContentCreatorFunction aCreator) { NS_PRECONDITION(aAttributes, "Got null attributes."); NS_PRECONDITION(aName, "Got null name."); @@ -91,13 +92,28 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, intendedParent->OwnerDoc()->NodeInfoManager() : mBuilder->GetNodeInfoManager(); - nsIContent* elem = - nsHtml5TreeOperation::CreateElement(aNamespace, - name, - aAttributes, - mozilla::dom::FROM_PARSER_FRAGMENT, - nodeInfoManager, - mBuilder); + nsIContent* elem; + if (aNamespace == kNameSpaceID_XHTML) { + elem = nsHtml5TreeOperation::CreateHTMLElement( + name, + aAttributes, + mozilla::dom::FROM_PARSER_FRAGMENT, + nodeInfoManager, + mBuilder, + aCreator.html); + } else if (aNamespace == kNameSpaceID_SVG) { + elem = nsHtml5TreeOperation::CreateSVGElement( + name, + aAttributes, + mozilla::dom::FROM_PARSER_FRAGMENT, + nodeInfoManager, + mBuilder, + aCreator.svg); + } else { + MOZ_ASSERT(aNamespace == kNameSpaceID_MathML); + elem = nsHtml5TreeOperation::CreateMathMLElement( + name, aAttributes, nodeInfoManager, mBuilder); + } if (MOZ_UNLIKELY(aAttributes != tokenizer->GetAttributes() && aAttributes != nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES)) { delete aAttributes; @@ -113,7 +129,8 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, aAttributes, content, aIntendedParent, - !!mSpeculativeLoadStage); + !!mSpeculativeLoadStage, + aCreator); // mSpeculativeLoadStage is non-null only in the off-the-main-thread // tree builder, which handles the network stream @@ -345,13 +362,15 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, } nsIContentHandle* -nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, +nsHtml5TreeBuilder::createElement(int32_t aNamespace, + nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes, nsIContentHandle* aFormElement, - nsIContentHandle* aIntendedParent) + nsIContentHandle* aIntendedParent, + nsHtml5ContentCreatorFunction aCreator) { - nsIContentHandle* content = createElement(aNamespace, aName, aAttributes, - aIntendedParent); + nsIContentHandle* content = + createElement(aNamespace, aName, aAttributes, aIntendedParent, aCreator); if (aFormElement) { if (mBuilder) { nsHtml5TreeOperation::SetFormElement(static_cast<nsIContent*>(content), @@ -368,10 +387,11 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, nsIContentHandle* nsHtml5TreeBuilder::createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* aAttributes) { - nsIContentHandle* content = createElement(kNameSpaceID_XHTML, - nsHtml5Atoms::html, - aAttributes, - nullptr); + nsHtml5ContentCreatorFunction creator; + // <html> uses NS_NewHTMLSharedElement creator + creator.html = NS_NewHTMLSharedElement; + nsIContentHandle* content = createElement( + kNameSpaceID_XHTML, nsHtml5Atoms::html, aAttributes, nullptr, creator); if (mBuilder) { nsresult rv = nsHtml5TreeOperation::AppendToDocument(static_cast<nsIContent*>(content), mBuilder); @@ -387,11 +407,13 @@ nsHtml5TreeBuilder::createHtmlElementSetAsRoot(nsHtml5HtmlAttributes* aAttribute } nsIContentHandle* -nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, nsIAtom* aName, +nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, + nsIAtom* aName, nsHtml5HtmlAttributes* aAttributes, nsIContentHandle* aFormElement, nsIContentHandle* aTable, - nsIContentHandle* aStackParent) + nsIContentHandle* aStackParent, + nsHtml5ContentCreatorFunction aCreator) { NS_PRECONDITION(aTable, "Null table"); NS_PRECONDITION(aStackParent, "Null stack parent"); @@ -403,8 +425,8 @@ nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, nsI static_cast<nsIContent*>(aTable), static_cast<nsIContent*>(aStackParent)); - nsIContentHandle* child = createElement(aNamespace, aName, aAttributes, - aFormElement, fosterParent); + nsIContentHandle* child = createElement( + aNamespace, aName, aAttributes, aFormElement, fosterParent, aCreator); insertFosterParentedChild(child, aTable, aStackParent); @@ -420,8 +442,8 @@ nsHtml5TreeBuilder::createAndInsertFosterParentedElement(int32_t aNamespace, nsI aStackParent, fosterParentHandle); // Create the element with the correct intended parent. - nsIContentHandle* child = createElement(aNamespace, aName, aAttributes, - aFormElement, fosterParentHandle); + nsIContentHandle* child = createElement( + aNamespace, aName, aAttributes, aFormElement, fosterParentHandle, aCreator); // Insert the child into the foster parent. insertFosterParentedChild(child, aTable, aStackParent); |