2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Implementation of DOM Core's nsIDOMDocumentType node.
|
|
|
|
*/
|
|
|
|
|
2012-12-28 17:34:02 -08:00
|
|
|
#include "mozilla/dom/DocumentType.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsDOMString.h"
|
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsIXPConnect.h"
|
2011-02-16 12:47:08 -08:00
|
|
|
#include "xpcpublic.h"
|
2011-05-26 12:58:35 -07:00
|
|
|
#include "nsWrapperCacheInlines.h"
|
2012-12-28 17:34:02 -08:00
|
|
|
#include "mozilla/dom/DocumentTypeBinding.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult
|
|
|
|
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
|
|
|
nsNodeInfoManager *aNodeInfoManager,
|
|
|
|
nsIAtom *aName,
|
|
|
|
const nsAString& aPublicId,
|
|
|
|
const nsAString& aSystemId,
|
|
|
|
const nsAString& aInternalSubset)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDocType);
|
2012-12-28 17:34:02 -08:00
|
|
|
mozilla::ErrorResult rv;
|
2012-12-28 17:34:02 -08:00
|
|
|
*aDocType = NS_NewDOMDocumentType(aNodeInfoManager, aName, aPublicId,
|
2014-03-15 12:00:15 -07:00
|
|
|
aSystemId, aInternalSubset, rv).take();
|
2012-12-28 17:34:02 -08:00
|
|
|
return rv.ErrorCode();
|
|
|
|
}
|
|
|
|
|
2012-12-28 17:34:02 -08:00
|
|
|
already_AddRefed<mozilla::dom::DocumentType>
|
2012-12-28 17:34:02 -08:00
|
|
|
NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
|
|
|
|
nsIAtom *aName,
|
|
|
|
const nsAString& aPublicId,
|
|
|
|
const nsAString& aSystemId,
|
|
|
|
const nsAString& aInternalSubset,
|
2012-12-28 17:34:02 -08:00
|
|
|
mozilla::ErrorResult& rv)
|
2012-12-28 17:34:02 -08:00
|
|
|
{
|
|
|
|
if (!aName) {
|
|
|
|
rv.Throw(NS_ERROR_INVALID_POINTER);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo> ni =
|
2012-07-30 07:20:58 -07:00
|
|
|
aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nullptr,
|
2011-09-17 06:32:32 -07:00
|
|
|
kNameSpaceID_None,
|
|
|
|
nsIDOMNode::DOCUMENT_TYPE_NODE,
|
|
|
|
aName);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-12-28 17:34:02 -08:00
|
|
|
nsRefPtr<mozilla::dom::DocumentType> docType =
|
2014-03-15 12:00:17 -07:00
|
|
|
new mozilla::dom::DocumentType(ni, aPublicId, aSystemId, aInternalSubset);
|
2012-12-28 17:34:02 -08:00
|
|
|
return docType.forget();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-28 17:34:02 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
JSObject*
|
2014-04-08 15:27:17 -07:00
|
|
|
DocumentType::WrapNode(JSContext *cx)
|
2012-12-28 17:34:02 -08:00
|
|
|
{
|
Bug 991742 part 6. Remove the "aScope" argument of binding Wrap() methods. r=bholley
This patch was mostly generated with this command:
find . -name "*.h" -o -name "*.cpp" | xargs sed -e 's/Binding::Wrap(aCx, aScope, this/Binding::Wrap(aCx, this/' -e 's/Binding_workers::Wrap(aCx, aScope, this/Binding_workers::Wrap(aCx, this/' -e 's/Binding::Wrap(cx, scope, this/Binding::Wrap(cx, this/' -i ""
plus a few manual fixes to dom/bindings/Codegen.py, js/xpconnect/src/event_impl_gen.py, and a few C++ files that were not caught in the search-and-replace above.
2014-04-08 15:27:17 -07:00
|
|
|
return DocumentTypeBinding::Wrap(cx, this);
|
2012-12-28 17:34:02 -08:00
|
|
|
}
|
|
|
|
|
2014-06-19 19:01:40 -07:00
|
|
|
DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2012-12-28 17:34:02 -08:00
|
|
|
const nsAString& aPublicId,
|
|
|
|
const nsAString& aSystemId,
|
|
|
|
const nsAString& aInternalSubset) :
|
|
|
|
DocumentTypeForward(aNodeInfo),
|
2007-03-22 10:30:00 -07:00
|
|
|
mPublicId(aPublicId),
|
|
|
|
mSystemId(aSystemId),
|
|
|
|
mInternalSubset(aInternalSubset)
|
|
|
|
{
|
2015-02-06 15:04:32 -08:00
|
|
|
NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::DOCUMENT_TYPE_NODE,
|
|
|
|
"Bad NodeType in aNodeInfo");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-28 17:34:02 -08:00
|
|
|
DocumentType::~DocumentType()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(DocumentType, nsGenericDOMDataNode, nsIDOMNode,
|
|
|
|
nsIDOMDocumentType)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool
|
2012-12-28 17:34:02 -08:00
|
|
|
DocumentType::IsNodeOfType(uint32_t aFlags) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// Don't claim to be eDATA_NODE since we're just inheriting
|
|
|
|
// nsGenericDOMDataNode for convinience. Doctypes aren't really
|
|
|
|
// data nodes (they have a null .nodeValue and don't implement
|
|
|
|
// nsIDOMCharacterData)
|
|
|
|
return !(aFlags & ~eCONTENT);
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsTextFragment*
|
2012-12-28 17:34:02 -08:00
|
|
|
DocumentType::GetText()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-28 17:34:02 -08:00
|
|
|
DocumentType::GetName(nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-14 00:56:49 -07:00
|
|
|
aName = NodeName();
|
2010-03-08 07:45:00 -08:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-28 17:34:02 -08:00
|
|
|
DocumentType::GetPublicId(nsAString& aPublicId)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aPublicId = mPublicId;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-28 17:34:02 -08:00
|
|
|
DocumentType::GetSystemId(nsAString& aSystemId)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aSystemId = mSystemId;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-28 17:34:02 -08:00
|
|
|
DocumentType::GetInternalSubset(nsAString& aInternalSubset)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
aInternalSubset = mInternalSubset;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-04-13 00:08:47 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
DocumentType::MozRemove()
|
|
|
|
{
|
|
|
|
Remove();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsGenericDOMDataNode*
|
2014-06-19 19:01:40 -07:00
|
|
|
DocumentType::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2014-06-19 19:01:40 -07:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo> ni = nsRefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
|
2014-03-15 12:00:17 -07:00
|
|
|
return new DocumentType(ni, mPublicId, mSystemId, mInternalSubset);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-12-28 17:34:02 -08:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|