Bug 851916 part 2 - createHTMLDocument() should work with no arguments; r=bz

This commit is contained in:
Aryeh Gregor 2013-03-21 14:55:08 +02:00
parent 16ce916fd5
commit a7b2b75371
6 changed files with 21 additions and 22 deletions

View File

@ -211,20 +211,22 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
rv = root->AppendChildTo(head, false);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> title;
rv = doc->CreateElem(NS_LITERAL_STRING("title"), nullptr, kNameSpaceID_XHTML,
getter_AddRefs(title));
NS_ENSURE_SUCCESS(rv, rv);
rv = head->AppendChildTo(title, 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);
rv = head->AppendChildTo(title, false);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> titleText;
rv = NS_NewTextNode(getter_AddRefs(titleText), doc->NodeInfoManager());
NS_ENSURE_SUCCESS(rv, rv);
rv = titleText->SetText(aTitle, false);
NS_ENSURE_SUCCESS(rv, rv);
rv = title->AppendChildTo(titleText, false);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIContent> titleText;
rv = NS_NewTextNode(getter_AddRefs(titleText), doc->NodeInfoManager());
NS_ENSURE_SUCCESS(rv, rv);
rv = titleText->SetText(aTitle, false);
NS_ENSURE_SUCCESS(rv, rv);
rv = title->AppendChildTo(titleText, false);
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsIContent> body;
rv = doc->CreateElem(NS_LITERAL_STRING("body"), nullptr, kNameSpaceID_XHTML,
@ -241,12 +243,14 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
}
already_AddRefed<nsIDocument>
DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
DOMImplementation::CreateHTMLDocument(const Optional<nsAString>& aTitle,
ErrorResult& aRv)
{
nsCOMPtr<nsIDocument> document;
nsCOMPtr<nsIDOMDocument> domDocument;
aRv = CreateHTMLDocument(aTitle, getter_AddRefs(document),
aRv = CreateHTMLDocument(aTitle.WasPassed() ? aTitle.Value()
: NullString(),
getter_AddRefs(document),
getter_AddRefs(domDocument));
return document.forget();
}

View File

@ -73,7 +73,7 @@ public:
ErrorResult& aRv);
already_AddRefed<nsIDocument>
CreateHTMLDocument(const nsAString& aTitle, ErrorResult& aRv);
CreateHTMLDocument(const Optional<nsAString>& aTitle, ErrorResult& aRv);
private:
nsresult CreateDocument(const nsAString& aNamespaceURI,

View File

@ -63,7 +63,6 @@
"Document interface: calling prepend(union) on xmlDoc with too few arguments must throw TypeError": true,
"Document interface: xmlDoc must inherit property \"append\" with the proper type (29)": true,
"Document interface: calling append(union) on xmlDoc with too few arguments must throw TypeError": true,
"DOMImplementation interface: operation createHTMLDocument(DOMString)": true,
"DocumentFragment interface: attribute children": true,
"DocumentFragment interface: attribute firstElementChild": true,
"DocumentFragment interface: attribute lastElementChild": true,

View File

@ -11,7 +11,6 @@ include $(DEPTH)/config/autoconf.mk
MOCHITEST_FILES := \
test_CharacterData-remove.html.json \
test_DOMImplementation-createHTMLDocument.html.json \
test_Document-createElementNS.html.json \
test_Document-getElementsByTagName.html.json \
test_DocumentType-remove.html.json \

View File

@ -23,5 +23,5 @@ interface DOMImplementation {
[TreatNullAs=EmptyString] DOMString qualifiedName,
DocumentType? doctype);
[Throws]
Document createHTMLDocument(DOMString title);
Document createHTMLDocument(optional DOMString title);
};