summaryrefslogtreecommitdiffstats
path: root/parser/html/nsHtml5TreeBuilderCppSupplement.h
diff options
context:
space:
mode:
Diffstat (limited to 'parser/html/nsHtml5TreeBuilderCppSupplement.h')
-rw-r--r--parser/html/nsHtml5TreeBuilderCppSupplement.h75
1 files changed, 49 insertions, 26 deletions
diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h
index aacc5a3e0..62df6d002 100644
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -68,9 +68,11 @@ nsHtml5TreeBuilder::~nsHtml5TreeBuilder()
}
nsIContentHandle*
-nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
+nsHtml5TreeBuilder::createElement(int32_t aNamespace,
+ nsIAtom* aName,
nsHtml5HtmlAttributes* aAttributes,
- nsIContentHandle* aIntendedParent)
+ nsIContentHandle* aIntendedParent,
+ nsHtml5ContentCreatorFunction aCreator)
{
NS_PRECONDITION(aAttributes, "Got null attributes.");
NS_PRECONDITION(aName, "Got null name.");
@@ -91,13 +93,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 +130,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
@@ -173,7 +191,7 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
type,
crossOrigin,
integrity,
- mode == NS_HTML5TREE_BUILDER_IN_HEAD);
+ mode == nsHtml5TreeBuilder::IN_HEAD);
mCurrentHtmlScriptIsAsyncOrDefer =
aAttributes->contains(nsHtml5AttributeName::ATTR_ASYNC) ||
aAttributes->contains(nsHtml5AttributeName::ATTR_DEFER);
@@ -279,7 +297,7 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName,
type,
crossOrigin,
integrity,
- mode == NS_HTML5TREE_BUILDER_IN_HEAD);
+ mode == nsHtml5TreeBuilder::IN_HEAD);
}
} else if (nsHtml5Atoms::style == aName) {
nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement();
@@ -345,13 +363,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 +388,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 +408,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 +426,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 +443,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);