mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-18 00:19:56 +00:00
Bug 945572 part 6. Make NS_NewElement take an Element** outparam instead of an nsIContent** one. r=smaug
This commit is contained in:
parent
888ac159c5
commit
728defdd23
@ -29,7 +29,7 @@ class Element;
|
||||
} // namespace mozilla
|
||||
|
||||
nsresult
|
||||
NS_NewElement(nsIContent** aResult,
|
||||
NS_NewElement(mozilla::dom::Element** aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo,
|
||||
mozilla::dom::FromParser aFromParser);
|
||||
|
||||
|
@ -4983,13 +4983,13 @@ nsIDocument::CreateElementNS(const nsAString& aNamespaceURI,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
rv = NS_NewElement(getter_AddRefs(content), nodeInfo.forget(),
|
||||
nsCOMPtr<Element> element;
|
||||
rv = NS_NewElement(getter_AddRefs(element), nodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
return dont_AddRef(content.forget().get()->AsElement());
|
||||
return element.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -7567,7 +7567,11 @@ nsDocument::CreateElem(const nsAString& aName, nsIAtom *aPrefix, int32_t aNamesp
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return NS_NewElement(aResult, nodeInfo.forget(), NOT_FROM_PARSER);
|
||||
nsCOMPtr<Element> element;
|
||||
nsresult rv = NS_NewElement(getter_AddRefs(element), nodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
element.forget(aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -189,45 +189,30 @@ NameSpaceManagerImpl::GetNameSpaceID(const nsAString& aURI)
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewElement(nsIContent** aResult,
|
||||
NS_NewElement(Element** aResult,
|
||||
already_AddRefed<nsINodeInfo> aNodeInfo, FromParser aFromParser)
|
||||
{
|
||||
int32_t ns = aNodeInfo.get()->NamespaceID();
|
||||
if (ns == kNameSpaceID_XHTML) {
|
||||
nsCOMPtr<Element> el;
|
||||
nsresult rv = NS_NewHTMLElement(getter_AddRefs(el), aNodeInfo, aFromParser);
|
||||
el.forget(aResult);
|
||||
return rv;
|
||||
return NS_NewHTMLElement(aResult, aNodeInfo, aFromParser);
|
||||
}
|
||||
#ifdef MOZ_XUL
|
||||
if (ns == kNameSpaceID_XUL) {
|
||||
nsCOMPtr<Element> el;
|
||||
nsresult rv = NS_NewXULElement(getter_AddRefs(el), aNodeInfo);
|
||||
el.forget(aResult);
|
||||
return rv;
|
||||
return NS_NewXULElement(aResult, aNodeInfo);
|
||||
}
|
||||
#endif
|
||||
if (ns == kNameSpaceID_MathML) {
|
||||
nsCOMPtr<Element> el;
|
||||
nsresult rv = NS_NewMathMLElement(getter_AddRefs(el), aNodeInfo);
|
||||
el.forget(aResult);
|
||||
return rv;
|
||||
return NS_NewMathMLElement(aResult, aNodeInfo);
|
||||
}
|
||||
if (ns == kNameSpaceID_SVG) {
|
||||
nsCOMPtr<Element> el;
|
||||
nsresult rv = NS_NewSVGElement(getter_AddRefs(el), aNodeInfo, aFromParser);
|
||||
el.forget(aResult);
|
||||
return rv;
|
||||
return NS_NewSVGElement(aResult, aNodeInfo, aFromParser);
|
||||
}
|
||||
if (ns == kNameSpaceID_XBL && aNodeInfo.get()->Equals(nsGkAtoms::children)) {
|
||||
NS_ADDREF(*aResult = new XBLChildrenElement(aNodeInfo));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<Element> el;
|
||||
nsresult rv = NS_NewXMLElement(getter_AddRefs(el), aNodeInfo);
|
||||
el.forget(aResult);
|
||||
return el;
|
||||
return NS_NewXMLElement(aResult, aNodeInfo);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1332,7 +1332,9 @@ nsXBLPrototypeBinding::ReadContentNode(nsIObjectInputStream* aStream,
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
NS_NewElement(getter_AddRefs(content), nodeInfo.forget(), NOT_FROM_PARSER);
|
||||
nsCOMPtr<Element> element;
|
||||
NS_NewElement(getter_AddRefs(element), nodeInfo.forget(), NOT_FROM_PARSER);
|
||||
content = element;
|
||||
|
||||
for (uint32_t i = 0; i < attrCount; i++) {
|
||||
rv = ReadNamespace(aStream, namespaceID);
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "nsTextNode.h"
|
||||
#include "mozilla/dom/CDATASection.h"
|
||||
#include "mozilla/dom/Comment.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/ProcessingInstruction.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
@ -462,7 +463,7 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, uint32_t aAttsCount,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<Element> content;
|
||||
rv = NS_NewElement(getter_AddRefs(content), ni.forget(), aFromParser);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -489,7 +490,7 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, uint32_t aAttsCount,
|
||||
}
|
||||
|
||||
if (!aNodeInfo->NamespaceEquals(kNameSpaceID_SVG)) {
|
||||
content.swap(*aResult);
|
||||
content.forget(aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -510,7 +511,7 @@ nsXMLContentSink::CreateElement(const PRUnichar** aAtts, uint32_t aAttsCount,
|
||||
}
|
||||
}
|
||||
|
||||
content.swap(*aResult);
|
||||
content.forget(aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsICSSLoaderObserver.h"
|
||||
#include "txStack.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
class nsIContent;
|
||||
class nsIDOMDocument;
|
||||
@ -96,7 +97,7 @@ private:
|
||||
// adding attributes to it).
|
||||
// until then the opened element is
|
||||
// kept in mOpenedElement
|
||||
nsCOMPtr<nsIContent> mOpenedElement;
|
||||
nsCOMPtr<mozilla::dom::Element> mOpenedElement;
|
||||
nsRefPtr<nsNodeInfoManager> mNodeInfoManager;
|
||||
|
||||
nsCOMArray<nsINode> mCurrentNodeStack;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsIDOMHTMLMenuItemElement.h"
|
||||
#include "nsXULContextMenuBuilder.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
@ -46,13 +47,13 @@ nsXULContextMenuBuilder::OpenContainer(const nsAString& aLabel)
|
||||
if (!mCurrentNode) {
|
||||
mCurrentNode = mFragment;
|
||||
} else {
|
||||
nsCOMPtr<nsIContent> menu;
|
||||
nsCOMPtr<Element> menu;
|
||||
nsresult rv = CreateElement(nsGkAtoms::menu, nullptr, getter_AddRefs(menu));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
menu->SetAttr(kNameSpaceID_None, nsGkAtoms::label, aLabel, false);
|
||||
|
||||
nsCOMPtr<nsIContent> menuPopup;
|
||||
nsCOMPtr<Element> menuPopup;
|
||||
rv = CreateElement(nsGkAtoms::menupopup, nullptr,
|
||||
getter_AddRefs(menuPopup));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -77,7 +78,7 @@ nsXULContextMenuBuilder::AddItemFor(nsIDOMHTMLMenuItemElement* aElement,
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> menuitem;
|
||||
nsCOMPtr<Element> menuitem;
|
||||
nsCOMPtr<nsIDOMHTMLElement> element = do_QueryInterface(aElement);
|
||||
nsresult rv = CreateElement(nsGkAtoms::menuitem, element,
|
||||
getter_AddRefs(menuitem));
|
||||
@ -129,7 +130,7 @@ nsXULContextMenuBuilder::AddSeparator()
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> menuseparator;
|
||||
nsCOMPtr<Element> menuseparator;
|
||||
nsresult rv = CreateElement(nsGkAtoms::menuseparator, nullptr,
|
||||
getter_AddRefs(menuseparator));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -203,7 +204,7 @@ nsXULContextMenuBuilder::Click(const nsAString& aGeneratedItemId)
|
||||
nsresult
|
||||
nsXULContextMenuBuilder::CreateElement(nsIAtom* aTag,
|
||||
nsIDOMHTMLElement* aHTMLElement,
|
||||
nsIContent** aResult)
|
||||
Element** aResult)
|
||||
{
|
||||
*aResult = nullptr;
|
||||
|
||||
|
@ -14,6 +14,12 @@ class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDOMHTMLElement;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
class nsXULContextMenuBuilder : public nsIMenuBuilder,
|
||||
public nsIXULContextMenuBuilder
|
||||
{
|
||||
@ -31,7 +37,7 @@ public:
|
||||
protected:
|
||||
nsresult CreateElement(nsIAtom* aTag,
|
||||
nsIDOMHTMLElement* aHTMLElement,
|
||||
nsIContent** aResult);
|
||||
mozilla::dom::Element** aResult);
|
||||
|
||||
nsCOMPtr<nsIContent> mFragment;
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
|
@ -3732,15 +3732,12 @@ XULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
|
||||
aPrototype->mNodeInfo->NamespaceID(),
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
if (!newNodeInfo) return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsINodeInfo> xtfNi = newNodeInfo;
|
||||
rv = NS_NewElement(getter_AddRefs(content), newNodeInfo.forget(),
|
||||
rv = NS_NewElement(getter_AddRefs(result), newNodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
result = content->AsElement();
|
||||
|
||||
rv = AddAttributes(aPrototype, result);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "nsNodeUtils.h"
|
||||
#include "mozAutoDocUpdate.h"
|
||||
#include "nsTextNode.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
#include "pldhash.h"
|
||||
#include "rdf.h"
|
||||
@ -248,7 +249,7 @@ protected:
|
||||
nsresult
|
||||
CreateElement(int32_t aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
nsIContent** aResult);
|
||||
Element** aResult);
|
||||
|
||||
/**
|
||||
* Set the container and empty attributes on a node. If
|
||||
@ -583,9 +584,11 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
else if (isGenerationElement) {
|
||||
// It's the "resource" element. Create a new element using
|
||||
// the namespace ID and tag from the template element.
|
||||
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(realKid));
|
||||
nsCOMPtr<Element> element;
|
||||
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(element));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
realKid = element.forget();
|
||||
|
||||
// Add the resource element to the content support map so
|
||||
// we can remove the match based on the content node later.
|
||||
@ -649,8 +652,10 @@ nsXULContentBuilder::BuildContentFromTemplate(nsIContent *aTemplateNode,
|
||||
}
|
||||
else {
|
||||
// It's just a generic element. Create it!
|
||||
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(realKid));
|
||||
nsCOMPtr<Element> element;
|
||||
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(element));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
realKid = element.forget();
|
||||
}
|
||||
|
||||
if (realKid && !realKidAlreadyExisted) {
|
||||
@ -1234,7 +1239,7 @@ nsXULContentBuilder::EnsureElementHasGenericChild(nsIContent* parent,
|
||||
|
||||
if (rv == NS_RDF_NO_VALUE) {
|
||||
// we need to construct a new child element.
|
||||
nsCOMPtr<nsIContent> element;
|
||||
nsCOMPtr<Element> element;
|
||||
|
||||
rv = CreateElement(nameSpaceID, tag, getter_AddRefs(element));
|
||||
if (NS_FAILED(rv))
|
||||
@ -1352,25 +1357,18 @@ nsXULContentBuilder::GetElementsForResult(nsIXULTemplateResult* aResult,
|
||||
nsresult
|
||||
nsXULContentBuilder::CreateElement(int32_t aNameSpaceID,
|
||||
nsIAtom* aTag,
|
||||
nsIContent** aResult)
|
||||
Element** aResult)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc = mRoot->GetDocument();
|
||||
NS_ASSERTION(doc != nullptr, "not initialized");
|
||||
if (! doc)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsIContent> result;
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo =
|
||||
doc->NodeInfoManager()->GetNodeInfo(aTag, nullptr, aNameSpaceID,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
|
||||
nsresult rv = NS_NewElement(getter_AddRefs(result), nodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
result.forget(aResult);
|
||||
return NS_OK;
|
||||
return NS_NewElement(aResult, nodeInfo.forget(), NOT_FROM_PARSER);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -357,7 +357,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
name = nsHtml5Atoms::select;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> newContent;
|
||||
nsCOMPtr<dom::Element> newContent;
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo = aBuilder->GetNodeInfoManager()->
|
||||
GetNodeInfo(name, nullptr, ns, nsIDOMNode::ELEMENT_NODE);
|
||||
NS_ASSERTION(nodeInfo, "Got null nodeinfo.");
|
||||
@ -404,7 +404,7 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
|
||||
for (uint32_t i = 0; i < theContent.Length(); ++i) {
|
||||
nsCOMPtr<nsIContent> optionElt;
|
||||
nsCOMPtr<dom::Element> optionElt;
|
||||
nsCOMPtr<nsINodeInfo> ni = optionNodeInfo;
|
||||
NS_NewElement(getter_AddRefs(optionElt),
|
||||
ni.forget(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user