Bug 675166 - Make DocumentTypeNode to use NodeInfoManager of the document, r=sicking

--HG--
extra : rebase_source : c05867591dc394695c35de92a0c62ca5df9db1d6
This commit is contained in:
Olli Pettay 2011-09-17 06:32:32 -07:00
Родитель a0dd8e028a
Коммит 3e3400ebbc
26 изменённых файлов: 142 добавлений и 240 удалений

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

@ -121,10 +121,6 @@
#define NS_XBLSERVICE_CID \
{ 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }
// 3a9cd622-264d-11d4-ba06-0060b0fc76dd
#define NS_DOM_IMPLEMENTATION_CID \
{ 0x3a9cd622, 0x264d, 0x11d4, {0xba, 0x06, 0x00, 0x60, 0xb0, 0xfc, 0x76, 0xdd } }
// {4aef38b7-6364-4e23-a5e7-12f837fbbd9c}
#define NS_XMLCONTENTSERIALIZER_CID \
{ 0x4aef38b7, 0x6364, 0x4e23, { 0xa5, 0xe7, 0x12, 0xf8, 0x37, 0xfb, 0xbd, 0x9c } }

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

@ -1884,7 +1884,8 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
PRBool aLoadedAsData);
PRBool aLoadedAsData,
nsIScriptGlobalObject* aEventObject);
nsresult
NS_NewPluginDocument(nsIDocument** aInstancePtrResult);

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

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIPrivateDOMImplementation_h__
#define nsIPrivateDOMImplementation_h__
#include "nsISupports.h"
class nsIURI;
class nsIPrincipal;
/*
* Event listener manager interface.
*/
#define NS_IPRIVATEDOMIMPLEMENTATION_IID \
{ /* 87c20441-8b0d-4383-a189-52fef1dd5d8a */ \
0x87c20441, 0x8b0d, 0x4383, \
{ 0xa1, 0x89, 0x52, 0xfe, 0xf1, 0xdd, 0x5d, 0x8a } }
class nsIPrivateDOMImplementation : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IPRIVATEDOMIMPLEMENTATION_IID)
NS_IMETHOD Init(nsIURI* aDocumentURI, nsIURI* aBaseURI,
nsIPrincipal* aPrincipal) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPrivateDOMImplementation,
NS_IPRIVATEDOMIMPLEMENTATION_IID)
nsresult
NS_NewDOMImplementation(nsIDOMDOMImplementation** aInstancePtrResult);
#endif // nsIPrivateDOMImplementation_h__

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

@ -3686,11 +3686,10 @@ nsContentUtils::CreateDocument(const nsAString& aNamespaceURI,
{
nsresult rv = NS_NewDOMDocument(aResult, aNamespaceURI, aQualifiedName,
aDoctype, aDocumentURI, aBaseURI, aPrincipal,
PR_TRUE);
PR_TRUE, aEventObject);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> document = do_QueryInterface(*aResult);
document->SetScriptHandlingObject(aEventObject);
// created documents are immediately "complete" (ready to use)
document->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);

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

@ -55,31 +55,16 @@
nsresult
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
nsNodeInfoManager *aNodeInfoManager,
nsIPrincipal *aPrincipal,
nsIAtom *aName,
const nsAString& aPublicId,
const nsAString& aSystemId,
const nsAString& aInternalSubset)
{
NS_PRECONDITION(aNodeInfoManager || aPrincipal,
"Must have a principal if no nodeinfo manager.");
NS_ENSURE_ARG_POINTER(aDocType);
NS_ENSURE_ARG_POINTER(aName);
nsRefPtr<nsNodeInfoManager> nimgr;
if (aNodeInfoManager) {
nimgr = aNodeInfoManager;
}
else {
nimgr = new nsNodeInfoManager();
nsresult rv = nimgr->Init(nsnull);
NS_ENSURE_SUCCESS(rv, rv);
nimgr->SetDocumentPrincipal(aPrincipal);
}
nsCOMPtr<nsINodeInfo> ni =
nimgr->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nsnull,
aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nsnull,
kNameSpaceID_None,
nsIDOMNode::DOCUMENT_TYPE_NODE,
aName);
@ -176,59 +161,3 @@ nsDOMDocumentType::CloneDataNode(nsINodeInfo *aNodeInfo, PRBool aCloneText) cons
mInternalSubset);
}
nsresult
nsDOMDocumentType::BindToTree(nsIDocument *aDocument, nsIContent *aParent,
nsIContent *aBindingParent,
PRBool aCompileEventHandlers)
{
if (!HasSameOwnerDoc(NODE_FROM(aParent, aDocument))) {
NS_ASSERTION(!GetOwnerDoc(), "Need to adopt or import first!");
// DocumentType nodes are the only nodes that can have a null ownerDocument
// according to the DOM spec, so we need to give them a new nodeinfo in that
// case.
// XXX We may want to move this to nsDOMImplementation::CreateDocument if
// we want to rely on the nodeinfo and wrappers being right before
// getting into ReplaceOrInsertBefore or doInsertChildAt. That would
// break inserting DOMDocumentType nodes through other DOM methods
// though.
nsNodeInfoManager *nimgr = aParent ?
aParent->NodeInfo()->NodeInfoManager() :
aDocument->NodeInfoManager();
nsCOMPtr<nsINodeInfo> newNodeInfo;
newNodeInfo = nimgr->GetNodeInfo(mNodeInfo->NameAtom(),
mNodeInfo->GetPrefixAtom(),
mNodeInfo->NamespaceID(),
nsIDOMNode::DOCUMENT_TYPE_NODE,
mNodeInfo->GetExtraName());
NS_ENSURE_TRUE(newNodeInfo, NS_ERROR_OUT_OF_MEMORY);
mNodeInfo.swap(newNodeInfo);
JSObject *oldScope = GetWrapper();
if (oldScope) {
nsIXPConnect *xpc = nsContentUtils::XPConnect();
JSContext *cx = nsnull;
JSObject *newScope = nsnull;
nsresult rv = nsContentUtils::GetContextAndScope(nsnull,
nimgr->GetDocument(),
&cx, &newScope);
if (cx && xpc) {
nsISupports *node = NS_ISUPPORTS_CAST(nsIContent*, this);
nsCOMPtr<nsIXPConnectJSObjectHolder> oldWrapper;
rv = xpc->ReparentWrappedNativeIfFound(cx, oldScope, newScope, node,
getter_AddRefs(oldWrapper));
}
if (NS_FAILED(rv)) {
mNodeInfo.swap(newNodeInfo);
return rv;
}
}
}
return nsGenericDOMDataNode::BindToTree(aDocument, aParent, aBindingParent,
aCompileEventHandlers);
}

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

@ -101,9 +101,6 @@ public:
// nsIContent overrides
virtual const nsTextFragment* GetText();
virtual nsresult BindToTree(nsIDocument *aDocument, nsIContent *aParent,
nsIContent *aBindingParent,
PRBool aCompileEventHandlers);
virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo,
PRBool aCloneText) const;
@ -117,8 +114,7 @@ protected:
nsresult
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
nsNodeInfoManager *aOwnerDoc,
nsIPrincipal *aPrincipal,
nsNodeInfoManager* aNodeInfoManager,
nsIAtom *aName,
const nsAString& aPublicId,
const nsAString& aSystemId,

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

@ -1321,46 +1321,33 @@ nsDOMStyleSheetSetList::GetSets(nsTArray<nsString>& aStyleSets)
class nsDOMImplementation : public nsIDOMDOMImplementation
{
public:
nsDOMImplementation(nsIScriptGlobalObject* aScriptObject,
nsDOMImplementation(nsIDocument* aOwner,
nsIScriptGlobalObject* aScriptObject,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal);
nsIURI* aBaseURI);
virtual ~nsDOMImplementation();
NS_DECL_ISUPPORTS
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMImplementation)
// nsIDOMDOMImplementation
NS_DECL_NSIDOMDOMIMPLEMENTATION
protected:
nsCOMPtr<nsIDocument> mOwner;
nsWeakPtr mScriptObject;
nsCOMPtr<nsIURI> mDocumentURI;
nsCOMPtr<nsIURI> mBaseURI;
nsCOMPtr<nsIPrincipal> mPrincipal;
};
nsresult
NS_NewDOMImplementation(nsIDOMDOMImplementation** aInstancePtrResult)
{
*aInstancePtrResult = new nsDOMImplementation(nsnull, nsnull, nsnull, nsnull);
if (!*aInstancePtrResult) {
return NS_ERROR_OUT_OF_MEMORY;
}
NS_ADDREF(*aInstancePtrResult);
return NS_OK;
}
nsDOMImplementation::nsDOMImplementation(nsIScriptGlobalObject* aScriptObject,
nsDOMImplementation::nsDOMImplementation(nsIDocument* aOwner,
nsIScriptGlobalObject* aScriptObject,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal)
: mScriptObject(do_GetWeakReference(aScriptObject)),
nsIURI* aBaseURI)
: mOwner(aOwner),
mScriptObject(do_GetWeakReference(aScriptObject)),
mDocumentURI(aDocumentURI),
mBaseURI(aBaseURI),
mPrincipal(aPrincipal)
mBaseURI(aBaseURI)
{
}
@ -1371,15 +1358,16 @@ nsDOMImplementation::~nsDOMImplementation()
DOMCI_DATA(DOMImplementation, nsDOMImplementation)
// QueryInterface implementation for nsDOMImplementation
NS_INTERFACE_MAP_BEGIN(nsDOMImplementation)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMImplementation)
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMImplementation)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMDOMImplementation)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMImplementation)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_1(nsDOMImplementation, mOwner)
NS_IMPL_ADDREF(nsDOMImplementation)
NS_IMPL_RELEASE(nsDOMImplementation)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMImplementation)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMImplementation)
NS_IMETHODIMP
@ -1399,6 +1387,7 @@ nsDOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
nsIDOMDocumentType** aReturn)
{
*aReturn = nsnull;
NS_ENSURE_STATE(mOwner);
nsresult rv = nsContentUtils::CheckQName(aQualifiedName);
NS_ENSURE_SUCCESS(rv, rv);
@ -1409,7 +1398,8 @@ nsDOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
// Indicate that there is no internal subset (not just an empty one)
nsAutoString voidString;
voidString.SetIsVoid(PR_TRUE);
return NS_NewDOMDocumentType(aReturn, nsnull, mPrincipal, name, aPublicId,
return NS_NewDOMDocumentType(aReturn, mOwner->NodeInfoManager(),
name, aPublicId,
aSystemId, voidString);
}
@ -1443,21 +1433,14 @@ nsDOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
return NS_ERROR_DOM_NAMESPACE_ERR;
}
if (aDoctype) {
nsCOMPtr<nsIDOMDocument> owner;
aDoctype->GetOwnerDocument(getter_AddRefs(owner));
if (owner) {
return NS_ERROR_DOM_WRONG_DOCUMENT_ERR;
}
}
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptObject);
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
return nsContentUtils::CreateDocument(aNamespaceURI, aQualifiedName, aDoctype,
mDocumentURI, mBaseURI, mPrincipal,
mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
scriptHandlingObject, aReturn);
}
@ -1465,15 +1448,15 @@ NS_IMETHODIMP
nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
nsIDOMDocument** aReturn)
{
*aReturn = NULL;
*aReturn = nsnull;
NS_ENSURE_STATE(mOwner);
nsCOMPtr<nsIDOMDocumentType> doctype;
// Indicate that there is no internal subset (not just an empty one)
nsAutoString voidString;
voidString.SetIsVoid(true);
nsresult rv = NS_NewDOMDocumentType(getter_AddRefs(doctype),
NULL, // aNodeInfoManager
mPrincipal, // aPrincipal
mOwner->NodeInfoManager(),
nsGkAtoms::html, // aName
EmptyString(), // aPublicId
EmptyString(), // aSystemId
@ -1489,7 +1472,8 @@ nsDOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
nsCOMPtr<nsIDOMDocument> document;
rv = nsContentUtils::CreateDocument(EmptyString(), EmptyString(),
doctype, mDocumentURI, mBaseURI,
mPrincipal, scriptHandlingObject,
mOwner->NodePrincipal(),
scriptHandlingObject,
getter_AddRefs(document));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
@ -4315,8 +4299,7 @@ nsDocument::GetImplementation(nsIDOMDOMImplementation** aImplementation)
nsIScriptGlobalObject* scriptObject =
GetScriptHandlingObject(hasHadScriptObject);
NS_ENSURE_STATE(scriptObject || !hasHadScriptObject);
mDOMImplementation = new nsDOMImplementation(scriptObject, uri, uri,
NodePrincipal());
mDOMImplementation = new nsDOMImplementation(this, scriptObject, uri, uri);
if (!mDOMImplementation) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -4806,6 +4789,7 @@ nsDocument::ImportNode(nsIDOMNode* aImportedNode,
case nsIDOMNode::TEXT_NODE:
case nsIDOMNode::CDATA_SECTION_NODE:
case nsIDOMNode::COMMENT_NODE:
case nsIDOMNode::DOCUMENT_TYPE_NODE:
{
nsCOMPtr<nsINode> imported = do_QueryInterface(aImportedNode);
NS_ENSURE_TRUE(imported, NS_ERROR_FAILURE);
@ -6119,6 +6103,7 @@ nsDocument::AdoptNode(nsIDOMNode *aAdoptedNode, nsIDOMNode **aResult)
case nsIDOMNode::TEXT_NODE:
case nsIDOMNode::CDATA_SECTION_NODE:
case nsIDOMNode::COMMENT_NODE:
case nsIDOMNode::DOCUMENT_TYPE_NODE:
{
// We don't want to adopt an element into its own contentDocument or into
// a descendant contentDocument, so we check if the frameElement of this
@ -6151,7 +6136,6 @@ nsDocument::AdoptNode(nsIDOMNode *aAdoptedNode, nsIDOMNode **aResult)
return NS_ERROR_NOT_IMPLEMENTED;
}
case nsIDOMNode::DOCUMENT_NODE:
case nsIDOMNode::DOCUMENT_TYPE_NODE:
case nsIDOMNode::ENTITY_NODE:
case nsIDOMNode::NOTATION_NODE:
{

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

@ -3594,15 +3594,9 @@ nsINode::doInsertChildAt(nsIContent* aKid, PRUint32 aIndex,
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, aNotify);
if (!HasSameOwnerDoc(aKid)) {
// DocumentType nodes are the only nodes that can have a null
// ownerDocument according to the DOM spec, and we need to allow
// inserting them w/o calling AdoptNode().
if (aKid->NodeType() != nsIDOMNode::DOCUMENT_TYPE_NODE ||
aKid->GetOwnerDoc()) {
rv = AdoptNodeIntoOwnerDoc(this, aKid);
NS_ENSURE_SUCCESS(rv, rv);
}
}
PRUint32 childCount = aChildArray.ChildCount();
NS_ENSURE_TRUE(aIndex <= childCount, NS_ERROR_ILLEGAL_VALUE);
@ -4113,9 +4107,7 @@ nsINode::ReplaceOrInsertBefore(PRBool aReplace, nsINode* aNewChild,
// DocumentType nodes are the only nodes that can have a null
// ownerDocument according to the DOM spec, and we need to allow
// inserting them w/o calling AdoptNode().
if (!HasSameOwnerDoc(newContent) &&
(nodeType != nsIDOMNode::DOCUMENT_TYPE_NODE ||
newContent->GetOwnerDoc())) {
if (!HasSameOwnerDoc(newContent)) {
res = AdoptNodeIntoOwnerDoc(this, aNewChild);
NS_ENSURE_SUCCESS(res, res);
}

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

@ -139,7 +139,6 @@ protected:
friend class nsXULPrototypeDocument;
friend nsresult NS_NewDOMDocumentType(nsIDOMDocumentType** ,
nsNodeInfoManager *,
nsIPrincipal *,
nsIAtom *,
const nsAString& ,
const nsAString& ,

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

@ -506,6 +506,7 @@ _TEST_FILES2 = \
test_bug675121.html \
file_bug675121.sjs \
test_bug654352.html \
test_bug675166.html \
test_bug682592.html \
bug682592-subframe.html \
bug682592-subframe-ref.html \

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

@ -27,7 +27,7 @@ function testHTMLDocuments(ids, isXHTML) {
ids[i],
null);
ok(docType1, "No doctype?");
ok(!docType1.ownerDocument, "docType shouldn't have ownerDocument!");
ok(docType1.ownerDocument, "docType should have ownerDocument!");
var doc1 = document.implementation.createDocument(null, null, docType1);
is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
ok(!doc1.documentElement, "Document shouldn't have document element!");
@ -64,7 +64,7 @@ function testSVGDocument() {
"-//W3C//DTD SVG 1.1//EN",
null);
ok(docType1, "No doctype?");
ok(!docType1.ownerDocument, "docType shouldn't have ownerDocument!");
ok(docType1.ownerDocument, "docType should have ownerDocument!");
var doc1 = document.implementation.createDocument(null, null, docType1);
is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
ok(!doc1.documentElement, "Document shouldn't have document element!");
@ -91,7 +91,7 @@ function testFooBarDocument() {
var docType1 =
document.implementation.createDocumentType("FooBar", "FooBar", null);
ok(docType1, "No doctype?");
ok(!docType1.ownerDocument, "docType shouldn't have ownerDocument!");
ok(docType1.ownerDocument, "docType should have ownerDocument!");
var doc1 = document.implementation.createDocument(null, null, docType1);
is(docType1.ownerDocument, doc1, "docType should have ownerDocument!");
ok(!doc1.documentElement, "Document shouldn't have document element!");

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

@ -0,0 +1,57 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=675166
-->
<head>
<title>Test for Bug 675166</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=675166">Mozilla Bug 675166</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 675166 **/
var dt = document.implementation.createDocumentType("html", null, null);
isnot(dt.ownerDocument, null, "DocumentType should have ownerDocument");
var d = document.implementation.createDocument(null, null, dt);
is(dt.ownerDocument, d, "DocumentType shouldn't have null ownerDocument");
try {
document.implementation.createDocument(null, null, dt);
ok(true, "Creating document using already bound document type shouldn't throw!");
} catch(ex) {
ok(false, "Creating document using already bound document type shouldn't throw!");
}
var d2 = document.implementation.createDocument(null, null, null);
var dt2 = document.implementation.createDocumentType("html", null, null);
d2.appendChild(dt2);
is(dt2.ownerDocument, d2, "DocumentType shouldn't have null ownerDocument");
is(document.ownerDocument, null, "Document's ownerDocument should be null!");
is(document.documentElement.ownerDocument, document,
"Element should have ownerDocument!")
is(dt2.parentNode, d2, "parentNode should be document!");
d2.removeChild(dt2);
is(dt2.parentNode, null, "parentNode should be null!");
d.adoptNode(dt2);
d2.adoptNode(dt2);
d2.appendChild(dt2);
is(dt2.parentNode, d2, "parentNode should be document!");
</script>
</pre>
</body>
</html>

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

@ -2452,7 +2452,7 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode)
nsAutoString voidString;
voidString.SetIsVoid(PR_TRUE);
rv = NS_NewDOMDocumentType(getter_AddRefs(docType),
mDocument->NodeInfoManager(), nsnull, nameAtom,
mDocument->NodeInfoManager(), nameAtom,
publicId, systemId, voidString);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -1245,7 +1245,7 @@ nsXMLContentSink::HandleDoctypeDecl(const nsAString & aSubset,
// Create a new doctype node
nsCOMPtr<nsIDOMDocumentType> docType;
rv = NS_NewDOMDocumentType(getter_AddRefs(docType), mNodeInfoManager, nsnull,
rv = NS_NewDOMDocumentType(getter_AddRefs(docType), mNodeInfoManager,
name, aPublicId, aSystemId, aSubset);
if (NS_FAILED(rv) || !docType) {
return rv;

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

@ -103,7 +103,8 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
PRBool aLoadedAsData)
PRBool aLoadedAsData,
nsIScriptGlobalObject* aEventObject)
{
// Note: can't require that aDocumentURI/aBaseURI/aPrincipal be non-null,
// since at least one caller (XMLHttpRequest) doesn't have decent args to
@ -153,6 +154,8 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
return rv;
}
d->SetScriptHandlingObject(aEventObject);
if (isHTML) {
nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(d);
NS_ASSERTION(htmlDoc, "HTML Document doesn't implement nsIHTMLDocument?");

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

@ -943,7 +943,7 @@ txMozillaXMLOutput::createResultDocument(const nsSubstring& aName, PRInt32 aNsID
nsAutoString voidString;
voidString.SetIsVoid(PR_TRUE);
rv = NS_NewDOMDocumentType(getter_AddRefs(documentType),
mNodeInfoManager, nsnull,
mNodeInfoManager,
doctypeName,
mOutputFormat.mPublicId,
mOutputFormat.mSystemId,

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

@ -77,6 +77,8 @@ var docName = 'createDocument03';
DOMImplementation should raise WRONG_DOCUMENT_ERR DOMException
if parameter doctype has been used with a different document.
The specification has changed! No exception should be thrown.
Invoke method createDocument(namespaceURI,qualifiedName,doctype) on
this domimplementation where doctype is the type of this document.
Method should raise WRONG_DOCUMENT_ERR DOMException.
@ -110,11 +112,12 @@ function createDocument03() {
success = false;
try {
aNewDoc = domImpl.createDocument(namespaceURI,qualifiedName,docType);
success = true;
}
catch(ex) {
success = (typeof(ex.code) != 'undefined' && ex.code == 4);
success = false;
}
assertTrue("throw_WRONG_DOCUMENT_ERR",success);
//assertTrue("no_throw_WRONG_DOCUMENT_ERR",success);
}
}

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

@ -83,6 +83,8 @@ var docName = 'createDocument04';
DOMImplementation should raise WRONG_DOCUMENT_ERR DOMException
if parameter doctype was created from a different implementation.
The specification has changed! No exception should be thrown.
Invoke method createDocument(namespaceURI,qualifiedName,doctype) on
a domimplementation that is different from this domimplementation.
Doctype is the type of this document.
@ -123,11 +125,12 @@ function createDocument04() {
success = false;
try {
aNewDoc = domImpl.createDocument(namespaceURI,qualifiedName,docType);
success = true;
}
catch(ex) {
success = (typeof(ex.code) != 'undefined' && ex.code == 4);
success = false;
}
assertTrue("throw_WRONG_DOCUMENT_ERR",success);
assertTrue("no_throw_WRONG_DOCUMENT_ERR",success);
}
}

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

@ -82,6 +82,8 @@ var docName = 'documentimportnode07';
DocumentType object. Since DocumentType nodes cannot be imported, a
NOT_SUPPORTED_ERR should be raised.
The specification has changed! No exception should be thrown.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core
@ -106,11 +108,12 @@ function documentimportnode07() {
success = false;
try {
imported = doc.importNode(docType,true);
success = true;
}
catch(ex) {
success = (typeof(ex.code) != 'undefined' && ex.code == 9);
success = false;
}
assertTrue("throw_NOT_SUPPORTED_ERR",success);
assertTrue("no_throw_NOT_SUPPORTED_ERR",success);
}
}

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

@ -81,6 +81,8 @@ var docName = 'documentimportnode08';
Using the method importNode with deep=true, try to import a newly created DOcumentType
node. Since DocumentType nodes cannot be imported, a NOT_SUPPORTED_ERR should be raised.
The specification has changed! No exception should be thrown.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core
@ -109,11 +111,12 @@ docType = domImpl.createDocumentType("test:root",nullNS,nullNS);
success = false;
try {
imported = doc.importNode(docType,true);
success = true;
}
catch(ex) {
success = (typeof(ex.code) != 'undefined' && ex.code == 9);
success = false;
}
assertTrue("throw_NOT_SUPPORTED_ERR",success);
assertTrue("no_throw_NOT_SUPPORTED_ERR",success);
}
}

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

@ -80,6 +80,8 @@ var docName = 'domimplementationcreatedocumenttype01';
publicIds and systemIds. Check if the the DocumentType node was created with its
ownerDocument attribute set to null.
The specification has changed! ownerDocument should not be null.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocument
@ -117,7 +119,7 @@ for(var indexN65629 = 0;indexN65629 < publicIds.length; indexN65629++) {
assertNotNull("domimplementationcreatedocumenttype01_newDocType",newDocType);
ownerDocument = newDocType.ownerDocument;
assertNull("domimplementationcreatedocumenttype01_ownerDocument",ownerDocument);
assertNotNull("domimplementationcreatedocumenttype01_ownerDocument",ownerDocument);
}

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

@ -80,6 +80,8 @@ var docName = 'domimplementationcreatedocumenttype02';
and a valid publicId and systemId. Check if the the DocumentType node was created
with its ownerDocument attribute set to null.
The specification has changed! ownerDocument should not be null.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#Level-2-Core-DOM-createDocType
@ -123,7 +125,7 @@ for(var indexN65655 = 0;indexN65655 < qualifiedNames.length; indexN65655++) {
assertNotNull("domimplementationcreatedocumenttype02_newDocType",newDocType);
ownerDocument = newDocType.ownerDocument;
assertNull("domimplementationcreatedocumenttype02_ownerDocument",ownerDocument);
assertNotNull("domimplementationcreatedocumenttype02_ownerDocument",ownerDocument);
}

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

@ -83,6 +83,8 @@ var docName = 'importNode16';
Document should raise NOT_SUPPORTED_ERR DOMException if
the type of node being imported is DocumentType.
The specification has changed! No exception should be thrown.
Retrieve document staff.xml and get its type.
Invoke method importNode(importedNode,deep) where importedNode
contains the document type of the staff.xml.
@ -120,11 +122,12 @@ function importNode16() {
success = false;
try {
node = doc.importNode(docType,false);
success = true;
}
catch(ex) {
success = (typeof(ex.code) != 'undefined' && ex.code == 9);
success = false;
}
assertTrue("throw_NOT_SUPPORTED_ERR",success);
assertTrue("no_throw_NOT_SUPPORTED_ERR",success);
}
}

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

@ -79,6 +79,8 @@ var docName = 'nodegetownerdocument01';
Create a new DocumentType node. Since this node is not used with any Document yet
verify if the ownerDocument is null.
The specification has changed! ownerDocument should not be null.
* @author IBM
* @author Neil Delima
* @see http://www.w3.org/TR/DOM-Level-2-Core/core#node-ownerDoc
@ -103,7 +105,7 @@ function nodegetownerdocument01() {
docType = domImpl.createDocumentType("mydoc",nullID,nullID);
ownerDoc = docType.ownerDocument;
assertNull("nodegetownerdocument01",ownerDoc);
assertNotNull("nodegetownerdocument01",ownerDoc);
}

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

@ -269,9 +269,6 @@ nsresult
NS_NewXULTreeBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult);
#endif
nsresult
NS_NewDOMImplementation(nsIDOMDOMImplementation**);
static void Shutdown();
#ifdef MOZ_XTF
@ -510,7 +507,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMUtils)
MAKE_CTOR(CreateNameSpaceManager, nsINameSpaceManager, NS_GetNameSpaceManager)
MAKE_CTOR(CreateDocumentViewer, nsIDocumentViewer, NS_NewDocumentViewer)
MAKE_CTOR(CreateHTMLDocument, nsIDocument, NS_NewHTMLDocument)
MAKE_CTOR(CreateDOMImplementation, nsIDOMDOMImplementation, NS_NewDOMImplementation)
MAKE_CTOR(CreateXMLDocument, nsIDocument, NS_NewXMLDocument)
MAKE_CTOR(CreateSVGDocument, nsIDocument, NS_NewSVGDocument)
MAKE_CTOR(CreateImageDocument, nsIDocument, NS_NewImageDocument)
@ -746,7 +742,6 @@ NS_DEFINE_NAMED_CID(IN_DOMUTILS_CID);
NS_DEFINE_NAMED_CID(NS_NAMESPACEMANAGER_CID);
NS_DEFINE_NAMED_CID(NS_DOCUMENT_VIEWER_CID);
NS_DEFINE_NAMED_CID(NS_HTMLDOCUMENT_CID);
NS_DEFINE_NAMED_CID(NS_DOM_IMPLEMENTATION_CID);
NS_DEFINE_NAMED_CID(NS_XMLDOCUMENT_CID);
NS_DEFINE_NAMED_CID(NS_SVGDOCUMENT_CID);
NS_DEFINE_NAMED_CID(NS_IMAGEDOCUMENT_CID);
@ -881,7 +876,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_NAMESPACEMANAGER_CID, false, NULL, CreateNameSpaceManager },
{ &kNS_DOCUMENT_VIEWER_CID, false, NULL, CreateDocumentViewer },
{ &kNS_HTMLDOCUMENT_CID, false, NULL, CreateHTMLDocument },
{ &kNS_DOM_IMPLEMENTATION_CID, false, NULL, CreateDOMImplementation },
{ &kNS_XMLDOCUMENT_CID, false, NULL, CreateXMLDocument },
{ &kNS_SVGDOCUMENT_CID, false, NULL, CreateSVGDocument },
{ &kNS_IMAGEDOCUMENT_CID, false, NULL, CreateImageDocument },

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

@ -592,7 +592,6 @@ nsHtml5TreeOperation::Perform(nsHtml5TreeOpExecutor* aBuilder,
voidString.SetIsVoid(PR_TRUE);
NS_NewDOMDocumentType(getter_AddRefs(docType),
aBuilder->GetNodeInfoManager(),
nsnull,
name,
publicId,
systemId,