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-11-05 20:58:04 +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/. */
|
|
|
|
|
|
|
|
/*
|
2018-03-19 22:15:39 +03:00
|
|
|
* Implementations of DOM Core's Comment node.
|
2012-11-05 20:58:04 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
2013-01-04 21:02:14 +04:00
|
|
|
#include "mozilla/dom/Comment.h"
|
|
|
|
#include "mozilla/dom/CommentBinding.h"
|
2014-03-28 00:38:33 +04:00
|
|
|
#include "mozilla/IntegerPrintfMacros.h"
|
2012-11-05 20:58:04 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace dom;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2020-02-21 13:41:47 +03:00
|
|
|
Comment::~Comment() = default;
|
2012-11-05 20:58:04 +04:00
|
|
|
|
2018-03-19 22:50:16 +03:00
|
|
|
already_AddRefed<CharacterData> Comment::CloneDataNode(
|
2014-06-20 06:01:40 +04:00
|
|
|
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfo;
|
2020-03-17 17:53:51 +03:00
|
|
|
auto* nim = ni->NodeInfoManager();
|
|
|
|
RefPtr<Comment> it = new (nim) Comment(ni.forget());
|
2018-03-19 22:50:16 +03:00
|
|
|
if (aCloneText) {
|
2012-11-05 20:58:04 +04:00
|
|
|
it->mText = mText;
|
|
|
|
}
|
|
|
|
|
2018-03-19 22:50:16 +03:00
|
|
|
return it.forget();
|
2012-11-05 20:58:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
void Comment::List(FILE* out, int32_t aIndent) const {
|
|
|
|
int32_t indx;
|
|
|
|
for (indx = aIndent; --indx >= 0;) fputs(" ", out);
|
|
|
|
|
2014-03-28 00:38:33 +04:00
|
|
|
fprintf(out, "Comment@%p refcount=%" PRIuPTR "<!--", (void*)this,
|
|
|
|
mRefCnt.get());
|
2012-11-05 20:58:04 +04:00
|
|
|
|
|
|
|
nsAutoString tmp;
|
|
|
|
ToCString(tmp, 0, mText.GetLength());
|
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
|
|
|
|
|
|
|
fputs("-->\n", out);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-02-26 01:05:29 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<Comment> Comment::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aData,
|
|
|
|
ErrorResult& aRv) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> window =
|
|
|
|
do_QueryInterface(aGlobal.GetAsSupports());
|
2013-05-13 17:22:30 +04:00
|
|
|
if (!window || !window->GetDoc()) {
|
|
|
|
aRv.Throw(NS_ERROR_FAILURE);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return window->GetDoc()->CreateComment(aData);
|
|
|
|
}
|
|
|
|
|
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* Comment::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return Comment_Binding::Wrap(aCx, this, aGivenProto);
|
2013-01-04 21:02:14 +04:00
|
|
|
}
|
|
|
|
|
2012-11-05 20:58:04 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|