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"
|
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> NS_NewDOMDocumentType(
|
2012-12-29 05:34:02 +04:00
|
|
|
nsNodeInfoManager* aNodeInfoManager, nsAtom* aName,
|
|
|
|
const nsAString& aPublicId, const nsAString& aSystemId,
|
2018-03-13 23:24:01 +03:00
|
|
|
const nsAString& aInternalSubset) {
|
|
|
|
MOZ_ASSERT(aName, "Must have a name");
|
2000-03-22 17:38:50 +03:00
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfoManager->GetNodeInfo(
|
2012-07-30 18:20:58 +04:00
|
|
|
nsGkAtoms::documentTypeNodeName, nullptr, 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 = new mozilla::dom::DocumentType(
|
2018-09-21 23:45:49 +03:00
|
|
|
ni.forget(), 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 {
|
|
|
|
|
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
|
|
|
JSObject* DocumentType::WrapNode(JSContext* cx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return DocumentType_Binding::Wrap(cx, this, aGivenProto);
|
2012-12-29 05:34:02 +04:00
|
|
|
}
|
|
|
|
|
2018-09-21 23:45:49 +03: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-09-21 23:45:49 +03:00
|
|
|
: CharacterData(std::move(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
|
|
|
|
2012-12-29 05:34:02 +04:00
|
|
|
bool DocumentType::IsNodeOfType(uint32_t aFlags) const { return false; }
|
2006-07-19 08:36:36 +04:00
|
|
|
|
2012-12-29 05:34:02 +04:00
|
|
|
const nsTextFragment* DocumentType::GetText() { return nullptr; }
|
2000-03-22 17:38:50 +03:00
|
|
|
|
2018-03-13 23:24:01 +03:00
|
|
|
void DocumentType::GetName(nsAString& aName) const { 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> DocumentType::CloneDataNode(
|
2014-06-20 06:01:40 +04:00
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const {
|
2018-09-21 23:45:49 +03:00
|
|
|
return do_AddRef(new DocumentType(do_AddRef(aNodeInfo), 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
|