2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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/. */
|
2000-03-22 17:38:50 +03:00
|
|
|
|
2006-03-30 12:03:04 +04:00
|
|
|
/*
|
2006-03-31 12:41:49 +04:00
|
|
|
* Implementation of DOM Core's nsIDOMDocumentType node.
|
2006-03-30 12:03:04 +04:00
|
|
|
*/
|
|
|
|
|
2012-12-29 05:34:02 +04:00
|
|
|
#include "mozilla/dom/DocumentType.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2000-03-22 17:38:50 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2004-04-01 23:44:17 +04:00
|
|
|
#include "nsDOMString.h"
|
2005-09-24 22:43:15 +04:00
|
|
|
#include "nsNodeInfoManager.h"
|
2006-11-22 21:35:05 +03:00
|
|
|
#include "nsIXPConnect.h"
|
2011-02-16 23:47:08 +03:00
|
|
|
#include "xpcpublic.h"
|
2011-05-26 23:58:35 +04:00
|
|
|
#include "nsWrapperCacheInlines.h"
|
2012-12-29 05:34:02 +04:00
|
|
|
#include "mozilla/dom/DocumentTypeBinding.h"
|
|
|
|
|
2000-03-22 17:38:50 +03:00
|
|
|
nsresult
|
|
|
|
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
|
2005-09-24 22:43:15 +04:00
|
|
|
nsNodeInfoManager *aNodeInfoManager,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom *aName,
|
2002-03-24 02:54:46 +03:00
|
|
|
const nsAString& aPublicId,
|
|
|
|
const nsAString& aSystemId,
|
|
|
|
const nsAString& aInternalSubset)
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aDocType);
|
2012-12-29 05:34:02 +04:00
|
|
|
mozilla::ErrorResult rv;
|
2012-12-29 05:34:02 +04:00
|
|
|
*aDocType = NS_NewDOMDocumentType(aNodeInfoManager, aName, aPublicId,
|
2014-03-15 23:00:15 +04:00
|
|
|
aSystemId, aInternalSubset, rv).take();
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-12-29 05:34:02 +04:00
|
|
|
}
|
|
|
|
|
2012-12-29 05:34:02 +04:00
|
|
|
already_AddRefed<mozilla::dom::DocumentType>
|
2012-12-29 05:34:02 +04:00
|
|
|
NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom *aName,
|
2012-12-29 05:34:02 +04:00
|
|
|
const nsAString& aPublicId,
|
|
|
|
const nsAString& aSystemId,
|
|
|
|
const nsAString& aInternalSubset,
|
2012-12-29 05:34:02 +04:00
|
|
|
mozilla::ErrorResult& rv)
|
2012-12-29 05:34:02 +04:00
|
|
|
{
|
|
|
|
if (!aName) {
|
|
|
|
rv.Throw(NS_ERROR_INVALID_POINTER);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2000-03-22 17:38:50 +03:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo> ni =
|
2012-07-30 18:20:58 +04:00
|
|
|
aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nullptr,
|
2011-09-17 17:32:32 +04:00
|
|
|
kNameSpaceID_None,
|
2018-01-30 07:10:53 +03:00
|
|
|
nsINode::DOCUMENT_TYPE_NODE, aName);
|
2000-03-22 17:38:50 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::dom::DocumentType> docType =
|
2014-03-15 23:00:17 +04:00
|
|
|
new mozilla::dom::DocumentType(ni, aPublicId, aSystemId, aInternalSubset);
|
2012-12-29 05:34:02 +04:00
|
|
|
return docType.forget();
|
2000-03-22 17:38:50 +03:00
|
|
|
}
|
|
|
|
|
2012-12-29 05:34:02 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
DocumentType::WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
|
2012-12-29 05:34:02 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return DocumentTypeBinding::Wrap(cx, this, aGivenProto);
|
2012-12-29 05:34:02 +04:00
|
|
|
}
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2012-12-29 05:34:02 +04:00
|
|
|
const nsAString& aPublicId,
|
|
|
|
const nsAString& aSystemId,
|
|
|
|
const nsAString& aInternalSubset) :
|
|
|
|
DocumentTypeForward(aNodeInfo),
|
2000-03-22 17:38:50 +03:00
|
|
|
mPublicId(aPublicId),
|
|
|
|
mSystemId(aSystemId),
|
|
|
|
mInternalSubset(aInternalSubset)
|
|
|
|
{
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_TYPE_NODE,
|
2015-02-10 01:34:50 +03:00
|
|
|
"Bad NodeType in aNodeInfo");
|
2000-03-22 17:38:50 +03:00
|
|
|
}
|
|
|
|
|
2012-12-29 05:34:02 +04:00
|
|
|
DocumentType::~DocumentType()
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(DocumentType, nsGenericDOMDataNode, nsIDOMNode,
|
|
|
|
nsIDOMDocumentType)
|
2000-03-22 17:38:50 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-12-29 05:34:02 +04:00
|
|
|
DocumentType::IsNodeOfType(uint32_t aFlags) const
|
2006-07-19 08:36:36 +04: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)
|
2017-10-25 18:19:11 +03:00
|
|
|
return false;
|
2006-07-19 08:36:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const nsTextFragment*
|
2012-12-29 05:34:02 +04:00
|
|
|
DocumentType::GetText()
|
2006-07-19 08:36:36 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-07-19 08:36:36 +04:00
|
|
|
}
|
2000-03-22 17:38:50 +03:00
|
|
|
|
2017-07-06 15:00:35 +03:00
|
|
|
NS_IMETHODIMP
|
2012-12-29 05:34:02 +04:00
|
|
|
DocumentType::GetName(nsAString& aName)
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
2011-06-14 11:56:49 +04:00
|
|
|
aName = NodeName();
|
2010-03-08 18:45:00 +03:00
|
|
|
return NS_OK;
|
2000-03-22 17:38:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-29 05:34:02 +04:00
|
|
|
DocumentType::GetPublicId(nsAString& aPublicId)
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
|
|
|
aPublicId = mPublicId;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-29 05:34:02 +04:00
|
|
|
DocumentType::GetSystemId(nsAString& aSystemId)
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
|
|
|
aSystemId = mSystemId;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-12-29 05:34:02 +04:00
|
|
|
DocumentType::GetInternalSubset(nsAString& aInternalSubset)
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
|
|
|
aInternalSubset = mInternalSubset;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-09-11 21:15:08 +04:00
|
|
|
nsGenericDOMDataNode*
|
2014-06-20 06:01:40 +04:00
|
|
|
DocumentType::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
|
2014-03-15 23:00:17 +04:00
|
|
|
return new DocumentType(ni, mPublicId, mSystemId, mInternalSubset);
|
2000-03-22 17:38:50 +03:00
|
|
|
}
|
2006-11-22 21:35:05 +03:00
|
|
|
|
2012-12-29 05:34:02 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|