mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 874838 - Make CreateElem return Element. r=khuey
This commit is contained in:
parent
63b0eff435
commit
1611b3c887
@ -210,25 +210,19 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
|
||||
|
||||
nsCOMPtr<nsIContent> root;
|
||||
rv = doc->CreateElem(NS_LITERAL_STRING("html"), nullptr, kNameSpaceID_XHTML,
|
||||
getter_AddRefs(root));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<Element> root = doc->CreateElem(NS_LITERAL_STRING("html"), nullptr,
|
||||
kNameSpaceID_XHTML);
|
||||
rv = doc->AppendChildTo(root, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> head;
|
||||
rv = doc->CreateElem(NS_LITERAL_STRING("head"), nullptr, kNameSpaceID_XHTML,
|
||||
getter_AddRefs(head));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<Element> head = doc->CreateElem(NS_LITERAL_STRING("head"), nullptr,
|
||||
kNameSpaceID_XHTML);
|
||||
rv = root->AppendChildTo(head, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!DOMStringIsNull(aTitle)) {
|
||||
nsCOMPtr<nsIContent> title;
|
||||
rv = doc->CreateElem(NS_LITERAL_STRING("title"), nullptr,
|
||||
kNameSpaceID_XHTML, getter_AddRefs(title));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<Element> title = doc->CreateElem(NS_LITERAL_STRING("title"),
|
||||
nullptr, kNameSpaceID_XHTML);
|
||||
rv = head->AppendChildTo(title, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -239,10 +233,8 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> body;
|
||||
rv = doc->CreateElem(NS_LITERAL_STRING("body"), nullptr, kNameSpaceID_XHTML,
|
||||
getter_AddRefs(body));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<Element> body = doc->CreateElem(NS_LITERAL_STRING("body"), nullptr,
|
||||
kNameSpaceID_XHTML);
|
||||
rv = root->AppendChildTo(body, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -5447,13 +5447,8 @@ nsIDocument::CreateElement(const nsAString& aTagName, ErrorResult& rv)
|
||||
nsContentUtils::ASCIIToLower(aTagName, lcTagName);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> content;
|
||||
rv = CreateElem(needsLowercase ? lcTagName : aTagName,
|
||||
nullptr, mDefaultElementType, getter_AddRefs(content));
|
||||
if (rv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
return dont_AddRef(content.forget().take()->AsElement());
|
||||
return CreateElem(needsLowercase ? lcTagName : aTagName, nullptr,
|
||||
mDefaultElementType);
|
||||
}
|
||||
|
||||
void
|
||||
@ -5797,13 +5792,10 @@ nsDocument::CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value*
|
||||
|
||||
nsDependentAtomString localName(definition->mLocalName);
|
||||
|
||||
nsCOMPtr<nsIContent> newElement;
|
||||
nsresult rv = document->CreateElem(localName, nullptr,
|
||||
definition->mNamespaceID,
|
||||
getter_AddRefs(newElement));
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
nsCOMPtr<Element> element =
|
||||
document->CreateElem(localName, nullptr, definition->mNamespaceID);
|
||||
NS_ENSURE_TRUE(element, true);
|
||||
|
||||
nsCOMPtr<Element> element = do_QueryInterface(newElement);
|
||||
if (definition->mLocalName != typeAtom) {
|
||||
// This element is a custom element by extension, thus we need to
|
||||
// do some special setup. For non-extended custom elements, this happens
|
||||
@ -5811,7 +5803,7 @@ nsDocument::CustomElementConstructor(JSContext* aCx, unsigned aArgc, JS::Value*
|
||||
document->SetupCustomElement(element, definition->mNamespaceID, &elemName);
|
||||
}
|
||||
|
||||
rv = nsContentUtils::WrapNative(aCx, newElement, newElement, args.rval());
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, element, element, args.rval());
|
||||
NS_ENSURE_SUCCESS(rv, true);
|
||||
|
||||
return true;
|
||||
@ -8600,9 +8592,9 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel)
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::CreateElem(const nsAString& aName, nsIAtom *aPrefix, int32_t aNamespaceID,
|
||||
nsIContent **aResult)
|
||||
already_AddRefed<Element>
|
||||
nsDocument::CreateElem(const nsAString& aName, nsIAtom *aPrefix,
|
||||
int32_t aNamespaceID)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
nsAutoString qName;
|
||||
@ -8621,19 +8613,16 @@ nsDocument::CreateElem(const nsAString& aName, nsIAtom *aPrefix, int32_t aNamesp
|
||||
"check caller.");
|
||||
#endif
|
||||
|
||||
*aResult = nullptr;
|
||||
|
||||
nsRefPtr<mozilla::dom::NodeInfo> nodeInfo;
|
||||
mNodeInfoManager->GetNodeInfo(aName, aPrefix, aNamespaceID,
|
||||
nsIDOMNode::ELEMENT_NODE,
|
||||
getter_AddRefs(nodeInfo));
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
NS_ENSURE_TRUE(nodeInfo, nullptr);
|
||||
|
||||
nsCOMPtr<Element> element;
|
||||
nsresult rv = NS_NewElement(getter_AddRefs(element), nodeInfo.forget(),
|
||||
NOT_FROM_PARSER);
|
||||
element.forget(aResult);
|
||||
return rv;
|
||||
return NS_SUCCEEDED(rv) ? element.forget() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1011,9 +1011,9 @@ public:
|
||||
|
||||
virtual nsresult Init();
|
||||
|
||||
virtual nsresult CreateElem(const nsAString& aName, nsIAtom *aPrefix,
|
||||
int32_t aNamespaceID,
|
||||
nsIContent **aResult) override;
|
||||
virtual already_AddRefed<Element> CreateElem(const nsAString& aName,
|
||||
nsIAtom* aPrefix,
|
||||
int32_t aNamespaceID) override;
|
||||
|
||||
virtual void Sanitize() override;
|
||||
|
||||
|
@ -152,8 +152,8 @@ typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
|
||||
} // namespace mozilla
|
||||
|
||||
#define NS_IDOCUMENT_IID \
|
||||
{ 0x6d18ec0b, 0x1f68, 0x4ae6, \
|
||||
{ 0x8b, 0x3d, 0x8d, 0x7d, 0x8b, 0x8e, 0x28, 0xd4 } }
|
||||
{ 0x292450a1, 0x285e, 0x4a09, \
|
||||
{ 0x9a, 0xf9, 0x61, 0xf9, 0xb1, 0xbd, 0x27, 0xcc } }
|
||||
|
||||
// Enum for requesting a particular type of document when creating a doc
|
||||
enum DocumentFlavor {
|
||||
@ -1372,10 +1372,11 @@ public:
|
||||
|
||||
/**
|
||||
* Create an element with the specified name, prefix and namespace ID.
|
||||
* Returns null if element name parsing failed.
|
||||
*/
|
||||
virtual nsresult CreateElem(const nsAString& aName, nsIAtom *aPrefix,
|
||||
int32_t aNamespaceID,
|
||||
nsIContent** aResult) = 0;
|
||||
virtual already_AddRefed<Element> CreateElem(const nsAString& aName,
|
||||
nsIAtom* aPrefix,
|
||||
int32_t aNamespaceID) = 0;
|
||||
|
||||
/**
|
||||
* Get the security info (i.e. SSL state etc) that the document got
|
||||
|
@ -880,8 +880,8 @@ nsXBLPrototypeBinding::Read(nsIObjectInputStream* aStream,
|
||||
mBaseTag = do_GetAtom(baseTag);
|
||||
}
|
||||
|
||||
aDocument->CreateElem(NS_LITERAL_STRING("binding"), nullptr, kNameSpaceID_XBL,
|
||||
getter_AddRefs(mBinding));
|
||||
mBinding = aDocument->CreateElem(NS_LITERAL_STRING("binding"), nullptr,
|
||||
kNameSpaceID_XBL);
|
||||
|
||||
nsCOMPtr<nsIContent> child;
|
||||
rv = ReadContentNode(aStream, aDocument, aDocument->NodeInfoManager(), getter_AddRefs(child));
|
||||
|
@ -125,15 +125,13 @@ createAndAddToResult(nsIAtom* aName, const nsSubstring& aValue,
|
||||
"invalid result-holder");
|
||||
|
||||
nsIDocument* doc = aResultHolder->OwnerDoc();
|
||||
nsCOMPtr<nsIContent> elem;
|
||||
nsresult rv = doc->CreateElem(nsDependentAtomString(aName),
|
||||
nullptr, kNameSpaceID_None,
|
||||
getter_AddRefs(elem));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<Element> elem = doc->CreateElem(nsDependentAtomString(aName),
|
||||
nullptr, kNameSpaceID_None);
|
||||
NS_ENSURE_TRUE(elem, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsRefPtr<nsTextNode> text = new nsTextNode(doc->NodeInfoManager());
|
||||
|
||||
rv = text->SetText(aValue, false);
|
||||
nsresult rv = text->SetText(aValue, false);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = elem->AppendChildTo(text, false);
|
||||
|
@ -175,10 +175,9 @@ txMozillaTextOutput::createResultDocument(nsIDOMDocument* aSourceDocument,
|
||||
RegisterNameSpace(NS_LITERAL_STRING(kTXNameSpaceURI), namespaceID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = mDocument->CreateElem(nsDependentAtomString(nsGkAtoms::result),
|
||||
nsGkAtoms::transformiix, namespaceID,
|
||||
getter_AddRefs(mTextParent));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mTextParent =
|
||||
mDocument->CreateElem(nsDependentAtomString(nsGkAtoms::result),
|
||||
nsGkAtoms::transformiix, namespaceID);
|
||||
|
||||
|
||||
rv = mDocument->AppendChildTo(mTextParent, true);
|
||||
|
@ -619,11 +619,9 @@ txMozillaXMLOutput::createTxWrapper()
|
||||
RegisterNameSpace(NS_LITERAL_STRING(kTXNameSpaceURI), namespaceID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIContent> wrapper;
|
||||
rv = mDocument->CreateElem(nsDependentAtomString(nsGkAtoms::result),
|
||||
nsGkAtoms::transformiix, namespaceID,
|
||||
getter_AddRefs(wrapper));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<Element> wrapper =
|
||||
mDocument->CreateElem(nsDependentAtomString(nsGkAtoms::result),
|
||||
nsGkAtoms::transformiix, namespaceID);
|
||||
|
||||
uint32_t i, j, childCount = mDocument->GetChildCount();
|
||||
#ifdef DEBUG
|
||||
|
@ -3719,11 +3719,9 @@ XULDocument::CreateTemplateBuilder(nsIContent* aElement)
|
||||
getter_AddRefs(bodyContent));
|
||||
|
||||
if (! bodyContent) {
|
||||
nsresult rv =
|
||||
bodyContent =
|
||||
document->CreateElem(nsDependentAtomString(nsGkAtoms::treechildren),
|
||||
nullptr, kNameSpaceID_XUL,
|
||||
getter_AddRefs(bodyContent));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nullptr, kNameSpaceID_XUL);
|
||||
|
||||
aElement->AppendChildTo(bodyContent, false);
|
||||
}
|
||||
|
@ -4652,11 +4652,8 @@ nsEditor::CreateHTMLContent(nsIAtom* aTag)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIContent> ret;
|
||||
nsresult res = doc->CreateElem(nsDependentAtomString(aTag), nullptr,
|
||||
kNameSpaceID_XHTML, getter_AddRefs(ret));
|
||||
NS_ENSURE_SUCCESS(res, nullptr);
|
||||
return dont_AddRef(ret.forget().take()->AsElement());
|
||||
return doc->CreateElem(nsDependentAtomString(aTag), nullptr,
|
||||
kNameSpaceID_XHTML);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
Loading…
Reference in New Issue
Block a user