Bug 1847546 - Other misc nsHtml5TreeOperation clean-ups. r=smaug

Remove useless namespacing, we have an using statement in the file
anyways.

Differential Revision: https://phabricator.services.mozilla.com/D185638
This commit is contained in:
Emilio Cobos Álvarez 2023-08-08 10:18:20 +00:00
Родитель d039143937
Коммит 46b5ba840a
1 изменённых файлов: 35 добавлений и 42 удалений

Просмотреть файл

@ -42,7 +42,6 @@
using namespace mozilla;
using namespace mozilla::dom;
using mozilla::dom::Document;
/**
* Helper class that opens a notification batch if the current doc
@ -208,7 +207,7 @@ nsHtml5TreeOperation::~nsHtml5TreeOperation() {
}
nsresult nsHtml5TreeOperation::AppendTextToTextNode(
const char16_t* aBuffer, uint32_t aLength, dom::Text* aTextNode,
const char16_t* aBuffer, uint32_t aLength, Text* aTextNode,
nsHtml5DocumentBuilder* aBuilder) {
MOZ_ASSERT(aTextNode, "Got null text node.");
MOZ_ASSERT(aBuilder);
@ -259,12 +258,12 @@ nsresult nsHtml5TreeOperation::Append(nsIContent* aNode, nsIContent* aParent,
}
nsresult nsHtml5TreeOperation::Append(nsIContent* aNode, nsIContent* aParent,
mozilla::dom::FromParser aFromParser,
FromParser aFromParser,
nsHtml5DocumentBuilder* aBuilder) {
Maybe<nsHtml5AutoPauseUpdate> autoPause;
Maybe<dom::AutoCEReaction> autoCEReaction;
dom::DocGroup* docGroup = aParent->OwnerDoc()->GetDocGroup();
if (docGroup && aFromParser != mozilla::dom::FROM_PARSER_FRAGMENT) {
Maybe<AutoCEReaction> autoCEReaction;
DocGroup* docGroup = aParent->OwnerDoc()->GetDocGroup();
if (docGroup && aFromParser != FROM_PARSER_FRAGMENT) {
autoCEReaction.emplace(docGroup->CustomElementReactionsStack(), nullptr);
}
nsresult rv = Append(aNode, aParent, aBuilder);
@ -385,7 +384,7 @@ nsresult nsHtml5TreeOperation::FosterParent(nsIContent* aNode,
nsresult nsHtml5TreeOperation::AddAttributes(nsIContent* aNode,
nsHtml5HtmlAttributes* aAttributes,
nsHtml5DocumentBuilder* aBuilder) {
dom::Element* node = aNode->AsElement();
Element* node = aNode->AsElement();
nsHtml5OtherDocUpdate update(node->OwnerDoc(), aBuilder->GetDocument());
int32_t len = aAttributes->getLength();
@ -405,7 +404,7 @@ nsresult nsHtml5TreeOperation::AddAttributes(nsIContent* aNode,
}
void nsHtml5TreeOperation::SetHTMLElementAttributes(
dom::Element* aElement, nsAtom* aName, nsHtml5HtmlAttributes* aAttributes) {
Element* aElement, nsAtom* aName, nsHtml5HtmlAttributes* aAttributes) {
int32_t len = aAttributes->getLength();
for (int32_t i = 0; i < len; i++) {
nsHtml5String val = aAttributes->getValueNoBoundsCheck(i);
@ -504,38 +503,37 @@ nsIContent* nsHtml5TreeOperation::CreateHTMLElement(
}
nsIContent* nsHtml5TreeOperation::CreateSVGElement(
nsAtom* aName, nsHtml5HtmlAttributes* aAttributes,
mozilla::dom::FromParser aFromParser, nsNodeInfoManager* aNodeInfoManager,
nsHtml5DocumentBuilder* aBuilder,
mozilla::dom::SVGContentCreatorFunction aCreator) {
nsAtom* aName, nsHtml5HtmlAttributes* aAttributes, FromParser aFromParser,
nsNodeInfoManager* aNodeInfoManager, nsHtml5DocumentBuilder* aBuilder,
SVGContentCreatorFunction aCreator) {
nsCOMPtr<nsIContent> newElement;
if (MOZ_LIKELY(aNodeInfoManager->SVGEnabled())) {
RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
RefPtr<NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
aName, nullptr, kNameSpaceID_SVG, nsINode::ELEMENT_NODE);
MOZ_ASSERT(nodeInfo, "Got null nodeinfo.");
mozilla::DebugOnly<nsresult> rv =
DebugOnly<nsresult> rv =
aCreator(getter_AddRefs(newElement), nodeInfo.forget(), aFromParser);
MOZ_ASSERT(NS_SUCCEEDED(rv) && newElement);
} else {
RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
RefPtr<NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
aName, nullptr, kNameSpaceID_disabled_SVG, nsINode::ELEMENT_NODE);
MOZ_ASSERT(nodeInfo, "Got null nodeinfo.");
// The mismatch between NS_NewXMLElement and SVGContentCreatorFunction
// argument types is annoying.
nsCOMPtr<dom::Element> xmlElement;
mozilla::DebugOnly<nsresult> rv =
nsCOMPtr<Element> xmlElement;
DebugOnly<nsresult> rv =
NS_NewXMLElement(getter_AddRefs(xmlElement), nodeInfo.forget());
MOZ_ASSERT(NS_SUCCEEDED(rv) && xmlElement);
newElement = xmlElement;
}
dom::Element* newContent = newElement->AsElement();
Element* newContent = newElement->AsElement();
aBuilder->HoldElement(newElement.forget());
if (MOZ_UNLIKELY(aName == nsGkAtoms::style)) {
if (auto* linkStyle = dom::LinkStyle::FromNode(*newContent)) {
if (auto* linkStyle = LinkStyle::FromNode(*newContent)) {
linkStyle->DisableUpdates();
}
}
@ -566,26 +564,26 @@ nsIContent* nsHtml5TreeOperation::CreateSVGElement(
nsIContent* nsHtml5TreeOperation::CreateMathMLElement(
nsAtom* aName, nsHtml5HtmlAttributes* aAttributes,
nsNodeInfoManager* aNodeInfoManager, nsHtml5DocumentBuilder* aBuilder) {
nsCOMPtr<dom::Element> newElement;
nsCOMPtr<Element> newElement;
if (MOZ_LIKELY(aNodeInfoManager->MathMLEnabled())) {
RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
RefPtr<NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
aName, nullptr, kNameSpaceID_MathML, nsINode::ELEMENT_NODE);
NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
mozilla::DebugOnly<nsresult> rv =
DebugOnly<nsresult> rv =
NS_NewMathMLElement(getter_AddRefs(newElement), nodeInfo.forget());
MOZ_ASSERT(NS_SUCCEEDED(rv) && newElement);
} else {
RefPtr<dom::NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
RefPtr<NodeInfo> nodeInfo = aNodeInfoManager->GetNodeInfo(
aName, nullptr, kNameSpaceID_disabled_MathML, nsINode::ELEMENT_NODE);
NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
mozilla::DebugOnly<nsresult> rv =
DebugOnly<nsresult> rv =
NS_NewXMLElement(getter_AddRefs(newElement), nodeInfo.forget());
MOZ_ASSERT(NS_SUCCEEDED(rv) && newElement);
}
dom::Element* newContent = newElement;
Element* newContent = newElement;
aBuilder->HoldElement(newElement.forget());
if (!aAttributes) {
@ -613,8 +611,7 @@ nsIContent* nsHtml5TreeOperation::CreateMathMLElement(
void nsHtml5TreeOperation::SetFormElement(nsIContent* aNode,
nsIContent* aParent) {
RefPtr<dom::HTMLFormElement> formElement =
dom::HTMLFormElement::FromNodeOrNull(aParent);
RefPtr formElement = HTMLFormElement::FromNodeOrNull(aParent);
NS_ASSERTION(formElement,
"The form element doesn't implement HTMLFormElement.");
nsCOMPtr<nsIFormControl> formControl(do_QueryInterface(aNode));
@ -623,9 +620,8 @@ void nsHtml5TreeOperation::SetFormElement(nsIContent* aNode,
FormControlType::FormAssociatedCustomElement &&
!aNode->AsElement()->HasAttr(nsGkAtoms::form)) {
formControl->SetForm(formElement);
} else if (HTMLImageElement* domImageElement =
dom::HTMLImageElement::FromNodeOrNull(aNode)) {
domImageElement->SetForm(formElement);
} else if (auto* image = HTMLImageElement::FromNodeOrNull(aNode)) {
image->SetForm(formElement);
}
}
@ -670,8 +666,7 @@ nsresult nsHtml5TreeOperation::AppendComment(nsIContent* aParent,
char16_t* aBuffer, int32_t aLength,
nsHtml5DocumentBuilder* aBuilder) {
nsNodeInfoManager* nodeInfoManager = aParent->OwnerDoc()->NodeInfoManager();
RefPtr<dom::Comment> comment =
new (nodeInfoManager) dom::Comment(nodeInfoManager);
RefPtr<Comment> comment = new (nodeInfoManager) Comment(nodeInfoManager);
NS_ASSERTION(comment, "Infallible malloc failed?");
nsresult rv = comment->SetText(aBuffer, aLength, false);
NS_ENSURE_SUCCESS(rv, rv);
@ -681,8 +676,8 @@ nsresult nsHtml5TreeOperation::AppendComment(nsIContent* aParent,
nsresult nsHtml5TreeOperation::AppendCommentToDocument(
char16_t* aBuffer, int32_t aLength, nsHtml5DocumentBuilder* aBuilder) {
RefPtr<dom::Comment> comment = new (aBuilder->GetNodeInfoManager())
dom::Comment(aBuilder->GetNodeInfoManager());
RefPtr<Comment> comment = new (aBuilder->GetNodeInfoManager())
Comment(aBuilder->GetNodeInfoManager());
NS_ASSERTION(comment, "Infallible malloc failed?");
nsresult rv = comment->SetText(aBuffer, aLength, false);
NS_ENSURE_SUCCESS(rv, rv);
@ -695,7 +690,7 @@ nsresult nsHtml5TreeOperation::AppendDoctypeToDocument(
nsHtml5DocumentBuilder* aBuilder) {
// Adapted from nsXMLContentSink
// Create a new doctype node
RefPtr<dom::DocumentType> docType =
RefPtr<DocumentType> docType =
NS_NewDOMDocumentType(aBuilder->GetNodeInfoManager(), aName, aPublicId,
aSystemId, VoidString());
return AppendToDocument(docType, aBuilder);
@ -703,10 +698,8 @@ nsresult nsHtml5TreeOperation::AppendDoctypeToDocument(
nsIContent* nsHtml5TreeOperation::GetDocumentFragmentForTemplate(
nsIContent* aNode) {
dom::HTMLTemplateElement* tempElem =
static_cast<dom::HTMLTemplateElement*>(aNode);
RefPtr<dom::DocumentFragment> frag = tempElem->Content();
return frag;
auto* tempElem = static_cast<HTMLTemplateElement*>(aNode);
return tempElem->Content();
}
nsIContent* nsHtml5TreeOperation::GetFosterParent(nsIContent* aTable,
@ -808,7 +801,7 @@ nsresult nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsresult operator()(const opCreateHTMLElement& aOperation) {
nsIContent** target = aOperation.mContent;
mozilla::dom::HTMLContentCreatorFunction creator = aOperation.mCreator;
HTMLContentCreatorFunction creator = aOperation.mCreator;
nsAtom* name = aOperation.mName;
nsHtml5HtmlAttributes* attributes = aOperation.mAttributes;
nsIContent* intendedParent =
@ -827,7 +820,7 @@ nsresult nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsresult operator()(const opCreateSVGElement& aOperation) {
nsIContent** target = aOperation.mContent;
mozilla::dom::SVGContentCreatorFunction creator = aOperation.mCreator;
SVGContentCreatorFunction creator = aOperation.mCreator;
nsAtom* name = aOperation.mName;
nsHtml5HtmlAttributes* attributes = aOperation.mAttributes;
nsIContent* intendedParent =
@ -988,7 +981,7 @@ nsresult nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
nsresult operator()(const opSetStyleLineNumber& aOperation) {
nsIContent* node = *(aOperation.mContent);
if (auto* linkStyle = dom::LinkStyle::FromNode(*node)) {
if (auto* linkStyle = LinkStyle::FromNode(*node)) {
linkStyle->SetLineNumber(aOperation.mLineNumber);
} else {
MOZ_ASSERT(nsNameSpaceManager::GetInstance()->mSVGDisabled,