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
|
|
|
/*
|
2018-03-13 23:24:01 +03:00
|
|
|
* Implementation of DOM Core's DocumentType 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"
|
|
|
|
|
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,
|
2018-03-13 23:24:01 +03:00
|
|
|
const nsAString& aInternalSubset)
|
2012-12-29 05:34:02 +04:00
|
|
|
{
|
2018-03-13 23:24:01 +03:00
|
|
|
MOZ_ASSERT(aName, "Must have a name");
|
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) :
|
2018-03-19 22:18:06 +03:00
|
|
|
CharacterData(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");
|
2018-04-15 13:46:24 +03:00
|
|
|
MOZ_ASSERT(!IsCharacterData());
|
2000-03-22 17:38:50 +03:00
|
|
|
}
|
|
|
|
|
2018-04-15 13:46:24 +03:00
|
|
|
DocumentType::~DocumentType() = default;
|
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
|
|
|
{
|
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
|
|
|
|
2018-03-13 23:24:01 +03:00
|
|
|
void
|
|
|
|
DocumentType::GetName(nsAString& aName) const
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
2011-06-14 11:56:49 +04:00
|
|
|
aName = NodeName();
|
2000-03-22 17:38:50 +03:00
|
|
|
}
|
|
|
|
|
2018-03-13 23:24:01 +03:00
|
|
|
void
|
|
|
|
DocumentType::GetPublicId(nsAString& aPublicId) const
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
|
|
|
aPublicId = mPublicId;
|
|
|
|
}
|
|
|
|
|
2018-03-13 23:24:01 +03:00
|
|
|
void
|
|
|
|
DocumentType::GetSystemId(nsAString& aSystemId) const
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
|
|
|
aSystemId = mSystemId;
|
|
|
|
}
|
|
|
|
|
2018-03-13 23:24:01 +03:00
|
|
|
void
|
|
|
|
DocumentType::GetInternalSubset(nsAString& aInternalSubset) const
|
2000-03-22 17:38:50 +03:00
|
|
|
{
|
|
|
|
aInternalSubset = mInternalSubset;
|
|
|
|
}
|
|
|
|
|
2018-03-19 22:50:16 +03:00
|
|
|
already_AddRefed<CharacterData>
|
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();
|
2018-03-19 22:50:16 +03:00
|
|
|
return do_AddRef(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
|
|
|
|
|